【问题标题】:How to deploy Spring-boot REST API in external tomcat如何在外部 tomcat 中部署 Spring-boot REST API
【发布时间】:2017-11-23 01:31:51
【问题描述】:

我有一个没有任何网页的 Spring-boot gradle 应用程序。这个应用程序有 REST api,当我将它作为 Spring boot 应用程序运行时,它被成功调用。

现在从 gradle 生成战争之后,当我尝试在 apache-tomcat-8.0.35 中部署它时,它正在被部署并且目录结构如下:-

但现在我无法使用 tomcat 端口 8080 访问我的 REST api。我已经检查过 tomcat 是否在http://localhost:8080。在调用 REST Api 时出现以下错误:

HTTP Status 403

谁能帮帮我。

谢谢

【问题讨论】:

  • 这似乎是访问禁止错误。请检查您的 tomcat 配置是否安装了任何过滤器或其他阻止访问的配置。
  • 启用安全性?
  • @PRATHAPS 我刚刚下载了一个新的 tomcat 副本并在其中部署了我的应用程序。

标签: java rest tomcat spring-boot


【解决方案1】:

在 build.gradle 中添加依赖:

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

并添加一个类:

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

【讨论】:

    猜你喜欢
    • 2016-03-28
    • 2016-11-04
    • 2016-12-29
    • 2016-02-13
    • 1970-01-01
    • 2018-09-06
    • 2018-06-26
    • 1970-01-01
    • 2018-02-27
    相关资源
    最近更新 更多