我有spring-boot应用程序,它首先打包到jar 使用
mvn clean package
我正在尝试将其作为
运行java -jar target/bootstep-0.0.1-SNAPSHOT.jar
但由于跟随错误而失败。
2015-04-24 16:06:45.425 INFO 27324 --- [ost-startStop-1] c.s.j.api.core.PackagesResourceConfig : Scanning for root resource and provider classes in the packages:
com.netflix.discovery
com.netflix.eureka
2015-04-24 16:06:45.470 ERROR 27324 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception starting filter servletContainer
com.sun.jersey.core.spi.scanning.ScannerException: IO error when scanning jar
..
..
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\springbootproject\target\bootstep-0.0.1-SNAPSHOT.jar!\lib\eureka-client-1.1.147.jar (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at com.sun.jersey.core.spi.scanning.uri.JarZipSchemeScanner.closing(JarZipSchemeScanner.java:123)
at com.sun.jersey.core.spi.scanning.uri.JarZipSchemeScanner.scan(JarZipSchemeScanner.java:75)
jar文件eureka-client-1.1.147.jar存在于jar内的lib文件夹中,而MANIFEST.MF也有条目。
请建议。
答案 0 :(得分:3)
问题是由于泽西岛的限制 - 它无法应对嵌套的JAR文件。您需要将Boot配置为在应用程序启动时自动解压缩包含JAX-RS资源的任何JAR,例如:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-core</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>