zoukankan      html  css  js  c++  java
  • springBoot项目替换lib下的依赖jar包 Unable to open nested entry BOOT-INF/lib/

    问题:

    springboot项目在使用压缩软件替换lib下的依赖包后,启动报错,报错内容如下:

    PS D: tmp> java -jar .epayBusiness-2.0.2-SNAPSHOT.jar
    Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/ojdbc7-12.1.0.2.0.jar
            at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:109)
            at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:87)
            at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:72)
            at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
            at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
    Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/ojdbc7-12.1.0.2.0.jar'
            at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:252)
            at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:237)
            at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:104)
            ... 4 more
    Caused by: java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/ojdbc7-12.1.0.2.0.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:285)
            at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:260)
            at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:248)
            ... 6 more
    原因:

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

    解决(本文以升级ojdbc包为例):

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

    步骤1:解压jar包   jar -xvf  *.jar

    PS D: tmp> jar -xvf *.jar
      已创建: META-INF/
      已解压: META-INF/MANIFEST.MF
      已创建: BOOT-INF/
      已创建: BOOT-INF/classes/
      已创建: BOOT-INF/classes/com/
    步骤2:替换jar包

    rm -rf BOOT-INF/lib/ojdbc14-10.2.0.4.0.jar
    mv ojdbc7-12.1.0.2.0.jar BOOT-INF/lib/
     
    步骤3:重新压缩jar

     jar -cfM0 new.jar BOOT-INF/ META-INF/ org/
     
     

  • 相关阅读:
    sql server实用要点全解
    C# EntityFramwork(Model First)使用要点
    c# linq查询语句详细使用介绍
    c# webapi2 实用详解
    create-react-app脚手架中配置sass
    redux使用教程详细介绍
    react-router4.x 实用例子(路由过渡动画、代码分割)
    react-router4.x 组件和api介绍
    leetcode-mid-backtracking -22. Generate Parentheses-NO
    leetcode-mid-backtracking-17. Letter Combinations of a Phone Number
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317273.html
Copyright © 2011-2022 走看看