[英]Usage of the maven-shade plugin's AppenderTransformer
Okay, I am running into the typical problem in which I need to create a uber jar, but my project dependencies has multiple spring.handlers and spring.schemas files. 好的,我遇到了需要创建uber jar的典型问题,但是我的项目依赖项包含多个spring.handlers和spring.schemas文件。 I have search around and figured out that my problem required me to use the maven-shade plugin, along with it's AppendingTransformer. 我四处搜寻,发现我的问题需要我使用maven-shade插件及其AppendingTransformer。 The problem is that when I add the configuration and run the goal it does not merge the files; 问题是,当我添加配置并运行目标时,它不会合并文件。 what's more, I can put a bogus classpath in for the appender or resource file and it does not complain, which lead me to believe that it is not even attempting to execute the transformer. 此外,我可以在附加程序或资源文件中放入伪造的类路径,并且它不会抱怨,这使我相信它甚至没有尝试执行转换器。
execute- mvn compile package shade:shade 执行-mvn编译软件包shade:shade
<build>
<finalName>mongo-dictionary</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
我将插件配置为pluginManagement元素的子代,一旦摆脱了pluginManagement标记,一切都将如广告所示那样工作。
where is this plugin configuration, can you ensure that it is in the right place - build -> plugins element of the project for which you are creating uber jar. 该插件配置在哪里,是否可以确保它在正确的位置-您要为其创建uber jar的项目的build-> plugins元素。 I have the same configuration which works for me. 我有适用于我的相同配置。
Also you don't need to execute shade:shade separately. 另外,您不需要单独执行shade:shade。 Running mvn package will do that for you. 运行mvn软件包将为您做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.