spring boot 部署到tomcat8

spring boot的pom.xml修改

jar
改为
war

添加

    org.springframework.boot
    spring-boot-starter-tomcat
    provided

启动类修改为

@SpringBootApplication
public class ApiApplication extends SpringBootServletInitializer{

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return super.configure(builder);
    }

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

maven打包

mvn clean package

生成war文件,eg:api-0.0.1-SNAPSHOT

tomcat8,进入Web Application Manager,点击Deploy,选择war文件,完成。

你可能感兴趣的:(spring boot 部署到tomcat8)