当前位置: 代码迷 >> 综合 >> renren-admin打war包tomcat访问404解决
  详细解决方案

renren-admin打war包tomcat访问404解决

热度:97   发布时间:2024-01-15 09:09:04.0

1修改项目中的启动类Application main class
*1)继承SpringBootServletInitializer并重载configure方法

@SpringBootApplication
public class Application extends SpringBootServletInitializer {
    @Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);}public static void main(String[] args) throws Exception {
    SpringApplication.run(Application.class, args);}}

2将pom.xml中的jar改成war

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><!-- ... --><packaging>war</packaging><!-- ... -->
</project>

3将内嵌的Servlet容器(Tomcat)排除

<dependencies><!-- … --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope></dependency><!-- … -->
</dependencies>

4参考官网文档
87.1 Create a Deployable War File

  相关解决方案