【问题标题】:Spring boot rest tomcat deployment errorspring boot rest tomcat部署报错
【发布时间】: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


【解决方案1】:

如果您将 spring-boot-starter-web 作为依赖项添加到您的 POM 文件中,
它将自动包含嵌入式 Web 容器(默认为 Tomcat)。
因此,只需直接执行 JAR 即可,无需将其部署到任何 Web 容器中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-06
    • 2017-11-23
    • 2016-03-28
    • 2015-02-06
    • 2014-09-04
    • 2015-03-10
    • 2018-12-05
    • 1970-01-01
    相关资源
    最近更新 更多