【发布时间】:2017-07-02 07:41:43
【问题描述】:
我无法使用我的 spring-boot with jersey 项目运行生成的 jar 文件。
我遇到的异常是:
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 1
通过 IDE(运行 Main 类)或使用 spring-boot:run 时,项目可以正常运行
以下是当前设置的详细信息:
包装:
jar
依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<version>1.5.1.RELEASE</version>
</dependency>
我的球衣配置(ResourceConfig)设置为扫描包
@Component
public class JerseyConfiguration extends ResourceConfig {
public JerseyConfiguration() {
packages(true, "com.my.base.jaxrs.packages");
}
}
spring-boot-maven-plugin 配置为: org.springframework.boot
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
我也没有使用 spring-boot-starter-parent,而是添加了 spring-boot-dependencies,如文档中所示。
【问题讨论】:
-
您正在执行什么命令来尝试运行生成的 jar ? 请发布所有异常日志。
-
java -jar myjarfile.jar 我的用例也与此类似:github.com/spring-projects/spring-boot/issues/3528
-
你的项目中有
MANIFEST.MF文件吗? -
是的。 MANIFEST.MF 包含在 META-INF 中生成的 jar 中
-
它包含
Main-Class属性?