Build with Dependencies

This question already has an answer here:

  • How can I create an executable JAR with dependencies using Maven? 33 answers

  • Remove the descriptorRefs and archive tag from your maven-compiler-plugin section.

    In order to generate a JAR with all the dependencies self contained. You need to put this into the build plugins section of your pom.

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>
                                com.test.your.main.class.goes.Here
                            </mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Create the JAR file by running the following at the command prompt.

    mvn clean compile assembly:single
    
    链接地址: http://www.djcxy.com/p/29618.html

    上一篇: 如何制作一个Maven项目的“胖罐子”?

    下一篇: 建立与依赖关系