手上有個(gè)項(xiàng)目需要以jar方式運(yùn)行,使用maven-shade-plugin插件構(gòu)建成功后,在服務(wù)器上運(yùn)行"nohup java -jar myProject.jar > /dev/null &"出錯(cuò),錯(cuò)誤信息:“Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes”,網(wǎng)上搜索了半天,發(fā)現(xiàn)一個(gè)解決辦法:? http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
在pom文件maven-shade-plugin插件的配置信息中添加:
<configuration>
? <filters>
? <filter>
? <artifact>*:*</artifact>
? <excludes>
? <exclude>META-INF/*.SF</exclude>
? <exclude>META-INF/*.DSA</exclude>
? <exclude>META-INF/*.RSA</exclude>
? </excludes>
? </filter>
? </filters>
? <!-- Additional configuration. -->
</configuration>
繼續(xù)運(yùn)行,之前的錯(cuò)誤解決了,卻提示新的錯(cuò)誤:“Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [applicationContext.xml]”
解決辦法是在構(gòu)建的時(shí)候加入META-INF/spring.schemas 和 META-INF/spring.handlers transformers,最終的maven-shade-plugin插件信息配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version> 1.7.1</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.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.zhilin.paopao.server.NIOServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
重新clean install打包,再次運(yùn)行之后問(wèn)題解決~
創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國(guó)云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開(kāi)啟,新人活動(dòng)云服務(wù)器買(mǎi)多久送多久。
名稱欄目:Maven構(gòu)建可運(yùn)行的jar包出錯(cuò)解決辦法-創(chuàng)新互聯(lián)
文章起源:http://chinadenli.net/article22/desicc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、品牌網(wǎng)站制作、Google、面包屑導(dǎo)航、企業(yè)網(wǎng)站制作、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容