将多个模块罐组合成一个 [英] Combine multiple module jars into a single one

查看:64
本文介绍了将多个模块罐组合成一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个Maven项目,这是我的项目结构:

Now I have a Maven project and here's my project structure:

| sound(parent)
| -- sound-service (sub-module)
| -- sound-start (sub-module)

soundpom中.我有以下内容:

In sound's pom. I have following:

<modules>
    <module>sound-service</module>
    <module>sound-start</module>
</modules>

依次单击清理-编译-软件包",IDEA IntelliJ帮助我为每个子模块创建两个JAR软件包.但是我想要的是一个包含所有依赖项和JAR库的单个JAR文件.我还在父根的pom文件中添加了以下maven插件,但我仍然无法获得完整的内容.

After click clean - compile - package in order, IDEA IntelliJ helps me create two JAR packages for each sub-module. But what I want is a single JAR file with all dependencies and JAR libraries included. I also added the following maven plugin in the pom file of parent root, but I still cannot get one JAR with the whole thing.

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
    <archive>
        <manifest>
            <mainClass>com.yct.Application</mainClass>
        </manifest>
    </archive>
    <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
</configuration>
<executions>
    <execution>
        <id>make-assembly</id> 
        <phase>package</phase> 
        <goals>
            <goal>single</goal>
        </goals>
    </execution>
</executions>
</plugin>

我错过了什么吗?我还需要在soundpom中添加其他依赖项吗?

Did I miss something? Do I also need to add some other dependencies in sound's pom?

推荐答案

jar-with-dependencies可以帮助您使用依赖项(而不是 modules <)构建 jar /em>.

jar-with-dependencies can help you build a jar with the dependencies, not modules.

尝试使用<dependencies></dependencies>,而不是使用<modules></modules>.

Instead of using <modules></modules>, try to use <dependencies></dependencies> instead.

这篇关于将多个模块罐组合成一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆