欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maven bouncycastle jar java.lang.SecurityException

程序员文章站 2022-07-13 10:36:52
...

 

用maven-shade-plugin 打包可运行jar,但因引用了bouncycastle 相关jar,打包出来的jar 运行后出现异常“java.lang.SecurityException: no manifest section for signature file entry”

 

网上google很久,才发现因bouncycastle相关的jar 原因,使用一般的maven-shad-plugin配置不可用,需修改新增如下:

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>${maven.shade.plugin.version}</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<!-- because no manifest section for signature file entry -->
							<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.csair.jar.Provider</mainClass>
								</transformer>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
									<resource>META-INF/spring.handlers</resource>
								</transformer>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
									<resource>META-INF/spring.schemas</resource>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

 

 

原文来自:

http://www.jamesswafford.com/2012/03/11/java-lang-securityexception-no-manifest-section-for-signature-file-entry/

相关标签: maven