java - 无法打开嵌套条目“WEB-INF/lib/example.jar”

标签 java spring spring-boot

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

Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108) at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:86) at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70) at org.springframework.boot.loader.Launcher.launch(Launcher.java:49) at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58) Caused by: java.io.IOException: Unable to open nested jar file 'WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class' at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:254) at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:239) at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103) ... 4 more Caused by: java.lang.IllegalStateException: Unable to open nested entry 'WEB-INF/lib/test-cts-chk-query-rest-app-1.0.5/com/testcorp/cts/chk/query/rest/app/ClearinghouseQueryRESTController.class'. 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:282) at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:262) at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:250) ... 6 more

有没有办法在gradle项目上解决这个问题?

最佳答案

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

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

关于java - 无法打开嵌套条目“WEB-INF/lib/example.jar”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56538751/

相关文章:

java - 如何使用 ExecutorService 单元测试对测试用例进行排序

java - 如何修复 Java 中的插件依赖错误

java - Spring Boot Jpa 中的三个实体相互连接时出现问题

java - Jhipster:应用程序正在运行,但浏览器上没有输出

java - 发送到主题时抛出 TimeoutException

java - 如何使用 SWT/Eclipse 在 Mac OS X 中执行 jar?

java - onPictureTaken 方法 - 以 tiff 形式获取数据?

java - Spring套件工具。文件夹和文件图标上有一些奇怪的桶和问号

java - 将输出记录到数据库中

java - 在 Spring Boot 应用程序和 hawt.io 中使用基本身份验证的 Jolokia