记一次奇怪的问题,本地开发运行的时候不会报错,打包运行后就报这个错误
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
网上找了很多资料,需要打包的时候把引入的jar包里面包含META-INF/*.SF
,META-INF/*.DSA
,META-INF/*.RSA
都过滤掉,在pom文件里面添加配置,mainClass换成自己的启动类就行
<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>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.tq.SdkDownloadMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>