从Spring Boot 1.3.7升级到1.4.0后Single jar启动失败 [英] SIngle jar startup failed after upgrade from Spring Boot 1.3.7 to 1.4.0

查看:197
本文介绍了从Spring Boot 1.3.7升级到1.4.0后Single jar启动失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Spring Boot 1.3.7升级到1.4.0后,我们无法再使用Spring Boot Maven插件作为单个jar构建来启动我们的应用程序.我们的应用程序是一个使用Jersey和Jetty的小型REST接口.我们使用Maven,而pom文件是非常标准的Spring Boot.

After upgrading from Spring Boot 1.3.7 to 1.4.0 we can no longer start our application as a single jar build with the Spring Boot Maven plugin. Our application is a small REST interface using Jersey and Jetty. We use Maven and our pom file is pretty standard Spring Boot.

我们仍然可以使用mvn spring-boot:run并从Eclipse中运行该应用程序,但是当作为单个jar球衣运行时,ResourceFinder抱怨它找不到.jar!/BOOT-INF/classes.

We can still run the application using mvn spring-boot:run and from within Eclipse, but when run as a single jar Jersey ResourceFinder complains that it cannot find .jar!/BOOT-INF/classes.

当我打开罐子的包装时,文件夹BOOT-INF/classes存在,其中包含预期的类和资源.

When I unpack the jar the folder BOOT-INF/classes is present and contains the expected classes and resources.

任何帮助表示赞赏.

2016-08-10 14:58:31.162 ERROR 16071 --- [           main] o.s.boot.SpringApplication               
: Application startup failed

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'jerseyConfig' defined in URL
[jar:file:/acmesource/acme/acme-core/acme-core-api/target/acme-core-api-0.1
SNAPSHOT.jar!/BOOT-INF/classes!/com/acme/core/api/JerseyConfig.class]: Bean 
instantiation via constructor failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.acme.core.api.JerseyConfig]: Constructor threw exception; nested 
exception is
org.glassfish.jersey.server.internal.scanning.ResourceFinderException:
java.io.FileNotFoundException: /acmesource/acme/acme-core/acme-core
api/target/acme-core-api-0.1-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory)

推荐答案

来自

对可执行jar布局的更改意味着在Jersey的类路径扫描中限制现在会影响可执行的jar文件 以及可执行的war文件.要变通解决此问题,您希望由Jersey扫描的类应打包在jar中,并作为依赖项包含在BOOT-INF/lib中.然后,Spring Boot启动器应为

The change to the layout of executable jars means that a limitation in Jersey's classpath scanning now affects executable jar files as well as executable war files. To work around the problem, classes that you wish to be scanned by Jersey should be packaged in a jar and included as a dependency in BOOT-INF/lib. The Spring Boot launcher should then be configured to unpack those jars on start up so that Jersey can scan their contents.

这篇关于从Spring Boot 1.3.7升级到1.4.0后Single jar启动失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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