在运行mvn package:shade shade
时,日志中包含以下内容:使用XYZ-shaded.jar替换XYZ.jar
但在我的目标目录中,我找不到阴影jar
这是关于maven shade的pom
尝试后,这个pom帮助了我
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>akkaexample.Akkmain</Main-Class>
</manifestEntries>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>akkaexample.Akkmain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:2)
检查输出jar文件是否为阴影?
Shade插件可能在这里替换原始文件,意味着用阴影版本覆盖它。
如果你希望最后得到两个jar文件(阴影和无阴影),你可能需要将shadedArtifactAttached
属性设置为true
:
定义阴影工件是否应作为分类器附加到原始工件。如果为false,则阴影jar将成为项目的主要工件