maven项目打jar包时包含依赖

在pom文件中加入如下配置即可:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <!-- 避免生成dependency-reduced-pom.xml文件 -->               
        <createDependencyReducedPom>false</createDependencyReducedPom>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>demo.CalcTopology</mainClass>
                    </transformer>
                </transformers>
                <artifactSet>
                </artifactSet>
                <!-- 指定打包后的jar文件名称和路径,也可以不指定 -- > <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile> </configuration> </execution> </executions> </plugin>

你可能感兴趣的:(maven项目打jar包时包含依赖)