简体   繁体   English

Maven阴影插件的AppenderTransformer的用法

[英]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.

相关问题 Maven Shade插件和DataNucleus问题 - Maven Shade Plugin and DataNucleus issue Spring 3 NamespaceHandler与Maven Shade插件有关 - Spring 3 NamespaceHandler issues with Maven Shade plugin Maven Shade插件和Spring资源导入:未引用的bean - Maven shade plugin and Spring resource import: unreferenced beans 两个应用程序中的jar冲突-Maven-shade-plugin重定位 - jar conflict in two applications - maven-shade-plugin relocation maven-shade-plugin类路径资源问题 - maven-shade-plugin class path resource issue 使用 maven-shade-plugin 时无法在测试中加载 ApplicationContext - Failed to load ApplicationContext in tests when maven-shade-plugin is used 基于maven profile的spring-boot项目跳过maven shade插件 - Skipping maven shade plugin in a spring-boot project based on maven profile 将SpringBoot配置添加为时如何使用maven-shade-plugin的“PropertiesMergingResourceTransformer”<dependencymanagement> 标签</dependencymanagement> - How to use "PropertiesMergingResourceTransformer" of maven-shade-plugin when adding SpringBoot configuration as <dependencyManagement> tag `spring-boot-maven-plugin` 和 `maven-compiler-plugin` 有什么区别? - What's the difference between `spring-boot-maven-plugin` and `maven-compiler-plugin`? 将系统属性导入到Maven插件的Spring上下文中 - Import system properties to maven plugin's Spring context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM