【发布时间】:2017-06-16 06:18:38
【问题描述】:
我有一个项目,其中包含两个名为 Test1 和 Test2 的类。
Test1 和 Test2 都不是主类。现在我有一个名为 cloudexe.jar 的依赖项,它有一个主类 ClassExecuter。现在我的问题是我希望 ClassExecuter 作为 test1.jar 和 test2.jar 的主类。
test1.jar 应该只包含 Test1 类及其所有依赖项,包括 cloudexe.jar 同样 test2.jar 应该只包含 Test2 类及其所有依赖项,包括 cloudexe.jar
现在当我打包 pom.xml 时,我得到了 test1.jar 和 test2.jar,但我得到如下所示
Exception in thread "main" java.lang.NoSuchMethodException: com.uber.Test1.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Class.java:1678)
at com.simontuffs.onejar.Boot.run(Boot.java:339)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
我的 pom.xml 如下所示
<build>
<plugins>
<plugin>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<id>build-first</id>
<configuration>
<mainClass>com.uber.Test1</mainClass>
<attachToBuild>true</attachToBuild>
<classifier>onejar</classifier>
<filename>test1.jar</filename>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
<execution>
<id>build-second</id>
<configuration>
<mainClass>com.uber.Test2</mainClass>
<attachToBuild>true</attachToBuild>
<classifier>onejar</classifier>
<filename>test2.jar</filename>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
谁能帮我解决这个问题
【问题讨论】:
标签: java eclipse maven maven-assembly-plugin onejar