java从多个maven模块构建可执行jar
我无法从多个maven模块构建单个可执行jar。 情况是这样的:我有三个maven模块:app->;坚持->;领域我有个爸爸妈妈。xml也是。我在这个pom maven组装插件中添加了:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.toys.app.Service</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
因此,当我在父pom目录(包含parent.pom和app、persistence和domain maven模块)的命令行中键入命令时:mvn assembly:assembly 它给出了我的下一个错误:
[INFO] ------------------------------------------------------------------------
[INFO] Building persistence 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ persistence ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ..................................... SUCCESS [3.147s]
[INFO] domain ............................................ SUCCESS [4.765s]
[INFO] persistence ....................................... FAILURE [0.570s]
[INFO] app ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.287s
[INFO] Finished at: Wed Sep 28 12:30:26 CEST 2011
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project persistence: Failed to create assembly: Failed to resolve dependencies for project: com.toys:persistence:jar:1.0-SNAPSHOT: Missing:
[ERROR] ----------
[ERROR] 1) com.toys:domain:jar:1.0-SNAPSHOT
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=com.toys -DartifactId=domain -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=com.toys -DartifactId=domain -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) com.toys:persistence:jar:1.0-SNAPSHOT
[ERROR] 2) com.toys:domain:jar:1.0-SNAPSHOT
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] com.toys:persistence:jar:1.0-SNAPSHOT
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :persistence
每一个maven生命周期都很好!有人能帮我吗
# 1 楼答案
尝试添加执行阶段:
# 2 楼答案
我建议您在应用程序、持久性和域项目的同一级别上添加项目“分发”
在转移到自己的项目后,我在尝试在反应堆POM中创建分布时也遇到了类似的问题——没有令人头痛的问题
此外,别忘了在反应堆项目中添加“分配”模块