I am trying to run a simple Rest HelloWorld program as described in https://spring.io/guides/gs/rest-service/. I have downloaded Spring and Maven and added the MAVEN_HOME and M3_HOME environment variables. I have run the mvn -v command successfully in Windows command prompt. I browsed to the initial directory where the pom.xml is located. Then I run mvn spring-root:run but I get the following error:
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\user.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
I have already searched for this error message on the internet but the suggestions are not solving my problem. Am I forgetting something related to any installation? Any idea or suggestion is highly appreciated.
Oh, I realized now I had same issue in the past...
To address
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project gs-rest-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed: Unable to find main class -> [Help 1]
You have to create Application class (something annotated with #SpringBootApplication)
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
or skip tests mvn clean install -DskipTests.
For mvnw spring-boot:run I'm getting ConnectException right now...
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
Exception in thread "main" java.net.ConnectException: Connection refused: connect
but it is very likely issue on my side...
Related
When i try to run mvn spring-boot:run to launch this project that has worked for others in the past I'm met with this error after the build fails:
terminal screenshot
Would love help from someone who has encountered this before. Error reads:
failed to execute goal
org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:run
(default-cli) on project resource-profile-repo: Application finished
with exit code: 1 -> [Help 1]
Thanks for the help! Turns out I didn't have the proper log in information in my .env for the Database so it was failing the build. User error
Part of my GitLab CI pipeline uses Maven ( mvn test ). Maven fails to build my test project with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project GenericTests: Fatal error compiling: invalid target release: 13 -> [Help 1]
I did some research and apparently setting JAVA_HOME to the location of JDK 13 would work, and it does, but only when I do it by hand locally via SSH.
In my pipeline, even if I export JAVA_HOME right before running mvn test I still get the same error.
script:
- export JAVA_HOME=/usr/java/jdk-13.0.2
- mvn test
Why does this work differently between GitLab CI and SSH? Could it have to do with the fact that GitLab CI is a non-interactive shell? What can I do to remedy this?
EDIT: I also tried to add a release tag in pom.xml like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>13</release>
</configuration>
</plugin>
but this only resulted in another error during build time:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project GenericTests: Fatal error compiling: invalid flag: --release -> [Help 1]
It turned out to be a mess-up on my part: mvn test was being executed by means of an alias, which was actually sudo mvn test. Hence why the environment variable wasn't being used and why I got Mojo permission denied errors locally when I tried to rerun tests.
I am running sonarqube from docker and it's working great for local projects, but when running it manually on a dockerized app it gives
[ERROR] SonarQube server [http://my-external-server-url:9000] can not be reached.
I ran it with maven in DEBUG mode and I got that
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project MY-PROJECT: Unable to execute SonarQube: Fail to get bootstrap index from server: No route to host (Host unreachable) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project MY-PROJECT: Unable to execute SonarQube
Am I missing something here ??
P.S. It's a dockerized java project so I'm running from inside the docker, unlike other php projects
I'm trying to make a release using the Maven release plugin, but I get an error
[ERROR] Command output:
[ERROR] GitLab: The project you were looking for could not be found.
[ERROR] fatal: The remote end hung up unexpectedly
In my pom.xml such settings:
<scm>
<developerConnection>scm:git:ssh://git#git.domain.ua/myproject/mylib.git</developerConnection>
<url>https://git.domain.ua/myproject/mylib</url>
<tag>HEAD</tag>
</scm>
My Jenkins job settings:
Repository URL: ssh://git#git.domain.ua/myproject/mylib.git
Credentials: my ssh-key also imported in Git repo as deploy key
Branch Specifier (blank for 'any'): */development
Maven Release goals and options: -Dresume=false release:branch javadoc:javadoc
DryRun goals and options: -Dresume=false -DdryRun=true release:prepare
As you can see from the logs, Git-plugin successfully clones a branch, but Maven cannot make a commit for some reason:
Cloning the remote Git repository
Cloning repository ssh://git#git.domain.ua/myproject/mylib.git
> git init /opt/jenkins/workspace/MYJOB # timeout=10
Fetching upstream changes from ssh://git#git.domain.ua/myproject/mylib.git
> git --version # timeout=10
using GIT_SSH to set credentials JENKINS(jenkins user with jenkins#USER)
git checkout development
Switched to a new branch 'development'
Branch development set up to track remote branch development from origin.
Parsing POMs
Established TCP socket on 44626
[INFO] Executing: /bin/sh -c cd /opt/jenkins/workspace/MYJOB && git push ssh://git#git.domain.ua/myproject/mylib.git refs/heads/development:refs/heads/development
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:branch (default-cli) on project MYPROJECT: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[JENKINS] Archiving /opt/jenkins/workspace/MYPROJECT/pom.xml to *****-SNAPSHOT.pom
[ERROR] Command output:
[ERROR] GitLab: The project you were looking for could not be found.
[ERROR] fatal: The remote end hung up unexpectedly
I guess Maven doesn't know anything about the key that uses the Git-plugin, but I can't figure out how to configure the Maven Release Plugin to use the same key?
Try doing this in your Jenkins job configuration:
Update the Branch Specifier (blank for 'any') to the syntax refs/heads/development.
Under SCM > Git > Additional Behaviours, select Checkout to specific local branch and then enter ** as the branch name.
Under Build Environment, select SSH Agent > Specific credentials, and then specify the same SSH key that you used for cloning the repository.
The error is in the clone via https protocol and the push via ssh protocol. You must define which protocol to use for the transfer. For comparison, use the result of the command: git remote show origin, with the scm parameter set in the pom.xml file.
Example:
<scm>
<connection>scm:git:git#github.com:user/repo-name.git</connection>
<developerConnection>scm:git:git#github.com:user/repo-name.git</developerConnection>
<url>git#github.com:user/repo-name.git</url>
<tag>HEAD</tag>
</scm>
try to remove the ssh:// and just use : scm:git:git#git.domain.ua/myproject/mylib.git
replace the url tag by a connection tag with the value : scm:git:git#git.domain.ua/myproject/mylib.git
In the end it's gonna be something like this :
scm:git:git#git.domain.ua/myproject/mylib.git
scm:git:git#git.domain.ua/myproject/mylib.git
Also the plugin is searching for a project "MYPROJECT" uppercase , or i guess in gitlab youhave "myproject", you can check and change all "MYPROJECT " reference to "myproject" and then try again.
Best regards,
I'm working on datastax cassandra java driver project using Maven. I've tried to build it successfully in local machine with maven and Eclipse.
However, when I deployed the project in Amazon AWS. Every time, I ran the exec:java -Dexec.mainClass=”com.example.cassandra.App”, which is a simple Hello World java file. However, I got an error:
[ec2-user#ip-172-31-18-93 simple-client]$ mvn exec:exec
-Dexec.mainClass=”com.example.cassandra.App”
Error:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default-cli) on project simple-client: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec are missing or invalid -> [Help 1]
However, sometime when i went into the target/classes and run java com.example.cassandra.App, it can show hello world! successfully. But when I add new java file like SimpleClient.java and compile it and run, it shows the error above.