SpringBoot打war包

排除Tomcat

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
                        <exclusions>
                            <exclusion>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-starter-tomcat</artifactId>
                            </exclusion>
                        </exclusions>
        </dependency>
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-tomcat</artifactId>
           <scope>provided</scope>
        </dependency>

主启动类


@Slf4j
@EnableAsync//开启异步任务
@EnableScheduling//开启定时任务
@EnableTransactionManagement//开启基于注解的事务
@SpringBootApplication
@MapperScan("com.botao.cms.dao")//扫描
public class CMSApplication extends SpringBootServletInitializer {
    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


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

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(CMSApplication.class);
    }
}
原文地址:https://www.cnblogs.com/botaoJava/p/14531229.html