maven插件: shade, assembly

shade插件的作用: 

通过版本的exclution无法解决jar冲突的问题, 

解决方案是把依赖的包打到本model的jar中,打包的时候由mvn plugin自动修改代码中的依赖jar包名

relocation配置会强制修改代码中的依赖包名 ==>

示例配置:

<build>

        <plugins>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                            <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                            <minimizeJar>false</minimizeJar>
                            <createSourcesJar>false</createSourcesJar>
                            <artifactSet>
                                <includes>
                                    <include>io.netty:netty-all</include>
                                </includes>
                            </artifactSet>
                            <relocations>
                                <relocation>
                                    <pattern>io.netty</pattern>
                                    <shadedPattern>com.mytest.shade.io.netty</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

  

猜你喜欢

转载自www.cnblogs.com/yszzu/p/9395114.html
今日推荐