suj*_*mar 0 java spring tomcat http-status-code-404
从 Eclipse 或 Intellij idea 运行 Spring Boot 应用程序时,它会在嵌入式 tomcat 服务器上运行。但是当部署在外部 tomcat 服务器上时,它会出现 404 错误。
确保您已完成以下步骤:
Run Code Online (Sandbox Code Playgroud)@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); } }
Run Code Online (Sandbox Code Playgroud)<!-- marked the embedded servlet container as provided --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
<packaging>war</packaging>
如果您仍然遇到问题,请粘贴任何特定错误以防万一。