Intellij鎵撳寘jar鏂囦欢锛屸€渏ava.lang.SecurityException: Invalid signature file digest for Manifest main att
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Intellij鎵撳寘jar鏂囦欢锛屸€渏ava.lang.SecurityException: Invalid signature file digest for Manifest main att相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/ips' title='ips'>ips 鍒犳帀 toolbar 鍛藉悕绌洪棿 鐩存帴 缁撴灉 title 鏃犳硶鎵惧埌 bar
寮€濮嬩娇鐢ㄥ涓嬩唬鐮佽繘琛屾墦鍖?/p>
<build> <!-- mvn assembly:assembly -Dmaven.test.skip=true --> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.fxc.rpc.impl.member.MemberProvider</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
缁撴灉鍑虹幇spring鍛藉悕绌洪棿鏃犳硶鎵惧埌鐨勯敊璇紝
org.xml.sax.SAXParseException: schema_reference.4: 鏃犳硶璇诲彇鏂规鏂囨。 鈥榟ttp://www.springframework.org/schema/beans/spring-beans.xsd鈥? 鍘熷洜涓?1) 鏃犳硶鎵惧埌鏂囨。; 2) 鏃犳硶璇诲彇鏂囨。; 3) 鏂囨。鐨勬牴鍏冪礌涓嶆槸 <xsd:schema>銆?/pre>
鎹煡鏄敱浜巗pring-core锛宻pring-aop姣忎竴涓猨ar涓兘鍖呭惈浜嗕竴濂梥pring.handlers锛宻pring.schemas鏂囦欢锛屼互鑷充簬鍦ㄦ墦鍖呰繃绋嬩腑鍙戠敓浜嗚鐩栵紝缃戜笂娌℃湁鎼滃埌浣跨敤maven-assembly-plugin鎻掍欢濡備綍瑙e喅姝ら棶棰橈紝澶у鏁颁汉寤鸿浣跨敤maven-shade-plugin鎻掍欢锛屼慨鏀瑰悗pom浠g爜濡備笅
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.fxc.rpc.impl.member.MemberProvider</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
鍐嶆鎵撳寘锛屽嚭鐜版枃浠剁鍚嶄笉鍚堟硶鐨勯棶棰?/p>
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
鍐嶆煡锛屽師鏉ユ槸鐢变簬鏌愪簺鍖呯殑閲嶅寮曠敤锛屼互鑷充簬鎵撳寘涔嬪悗鐨凪ETA-INF鐨勭洰褰曚笅澶氬嚭浜嗕竴浜?.SF,*.DSA,*.RSA鏂囦欢鎵€鑷达紙鎹瑙e帇jar鍖咃紝鐒跺悗鍒犳帀杩欎簺鏂囦欢鍐嶆鎵撳寘閿欒灏变細娑堝け锛屾湭纭锛夛紝鍐嶆淇敼pom.xml锛屾渶缁堜娇鐢ㄥ涓嬮厤缃枃浠讹紝杩愯
mvn clean install -Dmaven.test.skip=true
鎵撳寘鎴愬姛
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</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.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.fxc.rpc.impl.member.MemberProvider</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
姝ゆ椂鏌ョ湅target鐩綍涓嬩細鍙戠幇xxx.jar 鍜宱riginal-xxx.jar锛屽悗涓€涓笉鍖呭惈寮曠敤鐨刯ar鍖咃紝鐩存帴杩愯鍓嶄竴涓嵆鍙?/p>
java -jar target/xxx.jar
鎴愬姛锛?/p>
PS锛氶」鐩腑浣跨敤浜嗗嚑涓叕鍙歌嚜宸辩殑jar锛屽湪鍏湁搴撻噷娌℃湁锛屽湪eclipse閲岃繍琛岀殑鏃跺€欐垜閮芥槸淇敼scope涓簊ystem锛岃皟鐢ㄧ殑鏈湴jar锛屼絾鏄湪鎵撳寘鐨勮繃绋嬩腑scope=system鐨刯ar鏄笉浼氳嚜宸辨墦杩涘幓鐨勶紝寰堟槸璁╂垜閮侀椃锛屾垜鍙ソ璁茶繖浜沯ar瀹夎杩涘叆鏈湴璧勬簮搴?/p>
mvn install:install-file -Dfile=my-jar.jar -DgroupId=org.richard -DartifactId=my-jar -Dversion=1.0 -Dpackaging=jar