zoukankan      html  css  js  c++  java
  • maven-shade-plugin插件使用的注意事项

    老项目(非SpringBoot)使用Spring+Dubbo,主要xml+部分注解配置。
    通过com.alibaba.dubbo.container.Main.main(args);启动容器,使用maven-shade-plugin插件打包。
    需要注意的是,如果自定义了Dubbo或Sentinel的SPI扩展,META-INF/services会覆盖同名文件,可能导致某些扩展未失效,需要手动在xml中配置,注意AppendingTransformer的配置。

    参考:
    http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
    https://github.com/alibaba/Sentinel/issues/1013

    <build>
            <finalName>demo</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                            <exclude>**/Log4j2Plugins.dat</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/services/com.alibaba.csp.sentinel.init.InitFunc</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/services/com.alibaba.csp.sentinel.slotchain.SlotChainBuilder</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/services/com.alibaba.csp.sentinel.command.CommandHandler</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/services/com.alibaba.csp.sentinel.transport.HeartbeatSender</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/services/com.alibaba.csp.sentinel.transport.CommandCenter</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>com.alibaba.dubbo.container.Main</mainClass>
                                    </transformer>
                                </transformers>
                                <createDependencyReducedPom>false</createDependencyReducedPom>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
  • 相关阅读:
    Dictionary<string, object>不区分大小写
    修改Windows远程桌面端口
    LookupError: unknown encoding: cp65001的问题
    Git命令基本操作备忘
    MariaDB10 修改默认密码
    android去除标题栏
    解决Eclipse中Android SDK Manager图标不见了的问题
    HTML邮件注意事项
    不同内核浏览器的差异以及浏览器渲染简介(转)
    DIV+CSS两种盒子模型
  • 原文地址:https://www.cnblogs.com/cdfive2018/p/12955185.html
Copyright © 2011-2022 走看看