spring-boot项目war包启动

spring-boot 项目 war包启动

1 修改打包方式为 war

<packaging>warpackaging>

2 启动类继承SpringBootServletInitializer 并Override configure方法 如下

public class SpringBootBootStrapExample extends SpringBootServletInitializer {
    
    public static void main(String[] args) {
        SpringApplication.run(SpringBootBootStrapExample.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootBootStrapExample.class);
    }

3 将 spring-boot-starter-tomcat 依赖改为provided

<dependency>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-tomcatartifactId>
		<scope>providedscope>
dependency>

你可能感兴趣的:(spring-boot)