在Centos 6.4 / Open JDK 1.7.0上运行Spring Boot jar时出现java.io.IOException [英] java.io.IOException when running Spring Boot jar on Centos 6.4 / Open JDK 1.7.0

查看:582
本文介绍了在Centos 6.4 / Open JDK 1.7.0上运行Spring Boot jar时出现java.io.IOException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Spring Boot(0.5.0.M7)生成的jar文件。当我们 mvn clean package然后在Windows 7(带有Oracle 64位Java SE JVM的64位1.7.0_51-b13)上运行( java -jar target / my-app-camel-0.1.0.jar)时),一切都按预期进行:

We have a spring boot (0.5.0.M7) generated jar file. When we "mvn clean package" and then run ("java -jar target/my-app-camel-0.1.0.jar") on Windows 7 (64 bit with Oracle 64-bit Java SE JVM, 1.7.0_51-b13) it all works as expected:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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版(最终版)(64位OS,带有OpenJDK 64位Java SE JVM 1.7.0_51-b02)上运行( java -jar target / my-app-camel-0.1.0.jar)失败:

However, when we "mvn clean package" and then run ("java -jar target/my-app-camel-0.1.0.jar") on CentOS release 6.4 (Final) (64 bit OS, with OpenJDK 64-bit Java SE JVM, 1.7.0_51-b02) it fails:

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时,它将提取

NOTE: When I "unzip my-app-camel.jar" on the Centos command line it extracts fine.

推荐答案

好像是本地maven缓存中的错误JAR文件(发生)。值得尝试的一件事实际上是使用 mvn spring-boot:run运行应用程序。如果您的JAR文件不正确,则可能会以这种方式显示。另一个方法是删除本地缓存的文件(例如,从〜/ .m2 /存储库中删除)并重建应用程序。

Looks like it was a bad JAR file in the local maven cache (it happens). One thing that's worth trying is actually running the app with "mvn spring-boot:run". If you have a bad JAR file it might show up that way. Another is to delete the local cached file (e.g. from "~/.m2/repository") and rebuild the application.

这篇关于在Centos 6.4 / Open JDK 1.7.0上运行Spring Boot jar时出现java.io.IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆