0
我有一個項目與兩個類命名爲Test1和Test2。一個jar與一個類和從依賴瓶主要類
Both Test1 and 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>
給出任何人都可以請幫我在這
感謝您的回覆,但其中'pom.xml'我將定義模塊' test1的 test2的 ' –
你需要太看的Maven多模塊項目。你有一位家長,然後有兩個孩子。每個孩子都在自己的目錄中。在構建父項時,它將構建它的每個子項,在您的情況下,每個子項都將在其目標文件夾中包含一個可執行jar。 –
但我需要一個類創建一個模塊項目.....如果我有10個類......那麼我需要創建10個模塊項目......是否有任何其他解決方案 –