[英]Caused by: java.io.IOException: Unable to open root Jar file 'file:/…/Sample/my-app/target/lib/spring-boot-actuator-autoconfigure-2.1.0.RELEASE.jar'
[英]java.io.IOException when running Spring Boot jar on Centos 6.4 / Open JDK 1.7.0
我们有一个spring boot(0.5.0.M7)生成的jar文件。 当我们“mvn clean package”然后在Windows 7上运行(“java -jar target / my-app-camel-0.1.0.jar”)(64位,带有Oracle 64位Java SE JVM,1.7.0_51-b13) )它都按预期工作:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v0.5.0.M7)
10:47:25.324 [main] INFO com.myco.myapp.Application - Starting Application on MYLAPTOP with PID 12260 (D:\Users\me\My Projects\Work\myco\myapp\src\myapp\my-app-camel\target\my-app-camel-0.1.0-SNAPSHOT.jar started by ME)
10:47:25.953 [main] INFO o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/camel-server.xml]
10:47:27.698 [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1e6d136c: startup date [Tue Jan 28 10:47:27 GMT 2014]; root of context hierarchy
...
但是,当我们“mvn clean package”然后在CentOS版本6.4(最终版)上运行(“java -jar target / my-app-camel-0.1.0.jar”)(64位操作系统,带有OpenJDK 64位Java SE JVM,1.7.0_51-b02)它失败了:
java.io.IOException: Unable to find ZIP central directory records after reading 206 bytes
at org.springframework.boot.loader.jar.CentralDirectoryEndRecord.<init>(CentralDirectoryEndRecord.java:64)
at org.springframework.boot.loader.jar.JarFile.loadJarEntries(JarFile.java:124)
at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:120)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFileFromFileEntry(JarFile.java:333)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:305)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:87)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:74)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:78)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:52)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:44)
注意:当我在Centos命令行上“解压缩my-app-camel.jar”时,它会提取正常。
看起来它在本地maven缓存中是一个糟糕的JAR文件(它发生)。 值得尝试的一件事实际上是使用“mvn spring-boot:run”运行应用程序。 如果你有一个糟糕的JAR文件,它可能会以这种方式出现。 另一种方法是删除本地缓存文件(例如从“〜/ .m2 / repository”)并重建应用程序。
我认为RC2可能已修复此问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.