【发布时间】:2016-11-04 08:03:25
【问题描述】:
我使用 Spring rest 和 Spring boot 创建了一个 rest api。当我尝试在 linux 服务器上的 tomcat 上部署它时,出现以下错误:
rror during ServletContainerInitializer processing
javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:160
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.server.ResourceConfig
我正在遵循 tomcat 的确切 Spring boot 指令。我的问题是我没有为我的应用程序(apis)使用任何与泽西岛相关的东西,那么它为什么要寻找泽西岛相关的代码,以及如何修复它。
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
控制器代码:
@RestController
@RequestMapping("/rest/cmscontent")
public class BatchController {
【问题讨论】:
-
你能分享你的 pom.xml,它可能包含问题
-
ClassNotFoundException的完整堆栈跟踪是什么? -
@Raja,我正在使用 Gradle,这里是 dependencies.compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot -starter-jersey") 提供运行时("org.springframework.boot:spring-boot-starter-tomcat") 编译("org.apache.commons:commons-lang3:3.4") 编译("net.sf.ehcache:ehcache :2.10.0") { exclude(group: "org.slf4j") } compile("org.springframework:spring-context-support") { exclude(module: 'quartz') } 因为,我没有使用 Jersey not当然,为什么要抱怨球衣
-
@Andy,系统不允许我发送...让我看看我是否可以在 googleDocs 上上传一些东西。
-
@Andy 我已将其上传到 googledocs。可以分享一下你的邮箱,我可以发给你。
标签: spring rest tomcat deployment spring-boot