【问题标题】:Unable to open nested entry 'WEB-INF/lib/example.jar无法打开嵌套条目 'WEB-INF/lib/example.jar
【发布时间】:2019-10-25 14:00:38
【问题描述】:

我有可执行的战争文件要运行,我从 WEB-INF/lib 文件夹中删除了一个 .jar 文件。再次将相同的 jar 文件添加到相同的路径中,但它无法运行它低于错误的 war 文件

线程“主”java.lang.IllegalStateException 中的异常:未能 获取嵌套存档以供输入 WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class 在 org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108) 在 org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:86) 在 org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70) 在 org.springframework.boot.loader.Launcher.launch(Launcher.java:49) 在 org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58) 原因:java.io.IOException:无法打开嵌套的 jar 文件 'WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class' 在 org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:254) 在 org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:239) 在 org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103) ... 4 更多原因:java.lang.IllegalStateException:无法打开 嵌套条目 'WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class'。 它已经被压缩并且嵌套的jar文件必须在没有的情况下存储 压缩。请检查用于创建可执行文件的机制 jar 文件位于 org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:282) 在 org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:262) 在 org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:250) ... 6 更多

有什么办法可以在 gradle 项目上解决这个问题吗?

【问题讨论】:

  • 有时我会遇到这种类型的问题............为了解决这个问题,我只需重新编译整个项目......或删除目标文件夹并重新运行我的 maven 项目……

标签: java spring spring-boot


【解决方案1】:

首先,如果您有一个 gradle 项目,那么您不需要添加外部 Jar,您可以编写一个 gradle 脚本来在您的程序中使用该 jar/class 文件。

第二件事,如果您刚刚在 Lib 目录中删除并添加了 jar,您需要清理并构建一次项目。

【讨论】:

    【解决方案2】:

    线程“main”java.lang.IllegalStateException 中的异常:无法获取条目的嵌套存档

    jar 文件不可执行。


    您可以使用以下内容。

    使用 spring bootJar 任务构建一个 jar。它默认是启用的,虽然只是为了确保 Gradle 使用 spring bootJar 任务构建 jar。

    bootJar { enabled true }
    

    禁用 jfxJar 任务。

    jfxJar { enabled false }
    

    提供 jfxAppOutputDir 的 bootJar 输出路径,同时提供 Spring boot JarLauncher 作为 mainClass。

    jfx {
        mainClass = 'org.springframework.boot.loader.JarLauncher'
    
        jfxAppOutputDir = "${buildDir.path}/libs"
    }
    

    enter link description here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-25
      • 2011-06-11
      • 2014-04-16
      • 1970-01-01
      • 2019-08-10
      • 2018-11-17
      • 1970-01-01
      • 2018-12-18
      相关资源
      最近更新 更多