【发布时间】:2021-01-09 20:20:45
【问题描述】:
我有一个 Springboot 项目,它有一个我可以从邮递员调用的 api。 当我使用 Main Class 运行应用程序时,我能够点击端点并获得响应。
但是,如果我使用项目之战将其部署在 tomcat 上,则同一端点会显示 404!
我错过了什么?
【问题讨论】:
标签: spring-boot spring-mvc spring-boot-actuator spring-boot-maven-plugin
我有一个 Springboot 项目,它有一个我可以从邮递员调用的 api。 当我使用 Main Class 运行应用程序时,我能够点击端点并获得响应。
但是,如果我使用项目之战将其部署在 tomcat 上,则同一端点会显示 404!
我错过了什么?
【问题讨论】:
标签: spring-boot spring-mvc spring-boot-actuator spring-boot-maven-plugin
可能有多种可能性
您没有将应用程序类扩展到 SpringBootServletInitializer。在这种情况下,spring boot 应用程序将不会部署到 tomcat。要解决此问题,请将“扩展 SpringBootServletInitializer”添加到您的主应用程序类
你打错了网址。确保将应用程序名称附加到 url。示例 - 如果 http://localhost:8080/data 在您的本地工作,并且您的应用程序名称是 app,您必须在部署时点击 http://{{serverip:port}}/app/data
应用程序属性有问题,例如配置的数据库是本地的,无法从 tomcat 等访问。要检查此类问题,请检查您的 tomcat 日志文件 (/{{tomcat dir}}/logs/catalina.out
【讨论】: