简体   繁体   English

在tomcat上部署Spring Boot应用程序时出现404错误

[英]When Spring Boot app is deployed on tomcat gives 404 error

Spring Boot application runs on embedded tomcat server when run it from Eclipse or intellij idea. 当从Eclipse或intellij idea运行Spring Boot应用程序时,它会在嵌入式tomcat服务器上运行。 But when deployed on external tomcat server it gives 404 error. 但是,当部署在外部tomcat服务器上时,会出现404错误。

Make sure you have done below steps: 确保您已完成以下步骤:

  1. Extends SpringBootServletInitializer 扩展SpringBootServletInitializer
 @SpringBootApplication public class SpringBootWebApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SpringBootWebApplication.class); } public static void main(String[] args) throws Exception { SpringApplication.run(SpringBootWebApplication.class, args); } } 
  1. Marked the embedded servlet container as provided in you pom.xml 将嵌入式servlet容器标记为pom.xml中提供的
 <!-- marked the embedded servlet container as provided --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> 
  1. Update packaging to war 更新包装以进行战争

<packaging>war</packaging>

  • Copy the generated war into Tomcat`s webapp folder and re-start tomcat. 将生成的war复制到Tomcat的webapp文件夹中,然后重新启动tomcat。
  • Go to admin page of tomcat and see if you can find your your app and its status is running/started.While accessing URL make sure you are appending right context path,if defined using "server.context" property in application.properties file. 转到tomcat的管理页面,查看是否可以找到自己的应用,并且其状态正在运行/启动。访问URL时,请确保要附加正确的上下文路径(如果使用application.properties文件中的“ server.context”属性定义)。

Paste any specific error in case otherwise,if you still face the issue. 如果仍然遇到问题,请粘贴任何特定的错误,以防万一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署在 Tomcat 中的 Spring Boot 给出 404,但可以独立运行 - Spring Boot Deployed in Tomcat gives 404 but works Stand-alone Spring Boot 应用程序在部署到 Tomcat 时提供 404,但适用于嵌入式服务器 - Spring Boot application gives 404 when deployed to Tomcat but works with embedded server Spring Boot War部署到tomcat给出了404错误 - spring boot war deployment to tomcat gives 404 error 部署在Tomcat上的Spring Boot Rest API可以提供404,但可以独立运行 - Spring Boot Rest API Deployed on Tomcat gives 404 but works Stand-alone all fine 使用ehcache部署Spring Boot应用程序时,Tomcat无法关闭 - Tomcat not shutting down when Spring boot app is deployed with ehcache 在Linux上部署Spring Boot应用程序时,日志文件端点上出现错误404 - Error 404 on logfile endpoint when the spring boot application is deployed on Linux Java Spring Tomcat 上的 MVC 应用程序给出错误 404 - Java Spring MVC app on Tomcat gives error 404 Spring Boot Web应用程序无法在Tomcat上运行-404错误 - Spring boot web app not working on Tomcat - 404 error Google App Engine Spring Boot 出现 404 错误 - Google App Engine Spring Boot gives a 404 error 部署在外部tomcat 9服务器上时,Spring Boot REST Controller返回404 - Spring Boot REST Controller returns 404 when deployed on external tomcat 9 server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM