https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/

1、首先你的pom文件中需要包含内嵌tomcat:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
 </dependency>
2、其次需要使用spring-boot-maven-plugin来打包pom中加上
    <build>
        <plugins>
            <!-- Package as an executable jar/war -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

 3、最后你的app要继承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);
    }

}

 

 

相关文章:

  • 2021-10-22
  • 2021-07-01
  • 2021-08-30
  • 2021-06-18
  • 2022-12-23
  • 2021-12-05
  • 2021-09-16
  • 2021-11-18
猜你喜欢
  • 2021-11-23
  • 2021-10-07
  • 2022-01-15
  • 2021-11-23
  • 2021-09-26
  • 2021-09-09
  • 2021-11-28
相关资源
相似解决方案