我第一次尝试使用Maven Shade并卡住了。我收到一条错误消息,上面写着:
Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.3:
shade for parameter outputFile: Cannot create instance of interface org.apache.maven.plugins.shade.resource.ResourceTransformer:
org.apache.maven.plugins.shade.resource.ResourceTransformer.<init>() -> [Help 1]
我为pom.xml扩展添加了这个模板,以便将Maven-Shade用于我的pom.xml,并进入我的测试项目的主类。
我不熟悉maven,尤其是这个插件 - 有人可以帮忙吗?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- Set the main class of the executable JAR -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.mavenShadeTest.MyMain</mainClass>
</transformer>
<!-- Merge the uimaFIT configuration files -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>
META-INF/org.apache.uima.fit/fsindexes.txt
</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>
META-INF/org.apache.uima.fit/types.txt
</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>
META-INF/org.apache.uima.fit/typepriorities.txt
</resource>
</transformer>
<!-- Prevent huge shaded artifacts from being deployed to a Maven
repository (remove if not desired) -->
<outputFile>
${project.build.directory}/${artifactId}-${version}-standalone.jar
</outputFile>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
答案 0 :(得分:1)
您已在outputFile
元素中添加了transformers
,而不是在外部:
</transformer>
<!-- Prevent huge shaded artifacts from being deployed to a Maven
repository (remove if not desired) -->
<outputFile>
${project.build.directory}/${artifactId}-${version}-standalone.jar
</outputFile>
</transformers>
</configuration>
将其移到外面,直接放在configuration
:
</transformers>
<outputFile>
${project.build.directory}/${artifactId}-${version}-standalone.jar
</outputFile>
</configuration>