Springboot使用外部Tomcat

2018-07-23 10:49:57
796次阅读
0个评论
1.重写springbootApp初始化方法

@SpringBootApplication
public class KafkaApplication extends SpringBootServletInitializer {

    //继承初始化类,并重写该方法
    public static void main(String[] args) {
        SpringApplication.run(KafkaApplication.class, args);
    }

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


2.修改pom.xml打包方式为war

<packaging>war</packaging>


3.增加pom.xml依赖

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


收藏00

登录 后评论。没有帐号? 注册 一个。