我有一个Maven项目,下面是目录结构:
maven_example/src
maven_example/target
在/src/main/java/maven_example/
我有三个.java
个文件:
Adder.java MainClass.java Subtractor.java
在/src/test/java/maven_example/
我有三个文件:
AllTests.java TestAdder.java TestSubtractor.java
以下是我的pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.infovision.maven_example</groupId>
<artifactId>maven_example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>src.main.java.maven_example.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<!-- http://mvnrepository.com/artifact/junit/junit -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
因此,当我从命令行运行mvn clean verify
时,它会成功。
但在Jenkins构建失败时出现以下错误消息:
[maven_example] $ /usr/lib/jvm/java-8-oracle/bin/java /usr/share/maven -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.5.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.59.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.5.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.5.jar 41467
Error: Could not find or load main class .usr.share.maven
ERROR: Failed to launch Maven. Exit code = 1
Finished: FAILURE
以下是我的Jenkins设置:
Root POM:/home/ishan/sf_shared/my_repo/maven/maven_example/pom.xml
目标和选项:clean verify
这里可能出现什么问题?