关注互联网应用及运维技术的个人博客

springBoot项目修改依赖jar包 Unable to open nested entry BOOT-INF/lib/

springboot项目在使用压缩软件修改依赖包配置项后,启动报错,报错内容如下

Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/bps-basic-properties-0.0.1-SNAPSHOT.jar'
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:256)
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:241)
	at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
	... 4 more
Caused by: java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/bps-basic-properties-0.0.1-SNAPSHOT.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
	at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:284)
	at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:264)
	at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:252)
	... 6 more

原因:

替换或者导入jar包时,jar包被自动压缩,springboot规定嵌套的jar包不能在被压缩的情况下存储。

解决办法

使用jar命令解压jar包,在压缩包外重新替换jar包,在进行压缩。

  1. 解压jar包 jar -xvf *.jar
[[email protected] jars]$ jar -xvf material-center.jar 
 created: META-INF/
 inflated: META-INF/MANIFEST.MF
 created: org/
 created: org/springframework/
 created: org/springframework/boot/
 created: org/springframework/boot/loader/
 created: org/springframework/boot/loader/data/
...
  1. 替换jar包

或者先用软件替换,不用再替换,我这里是7z替换好后解压的。

// 先删除再新增
rm -rf BOOT-INF/lib/xxx.jar
mv xxx.jar BOOT-INF/lib/
  1. 重新压缩jar
jar -cfM0 name.jar BOOT-INF/ META-INF/ org/

然后就可以正常用咯。

赞(0)
未经允许不得转载:飞天狒狒 » springBoot项目修改依赖jar包 Unable to open nested entry BOOT-INF/lib/

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址