idea 发布springboot应用到Tomcat 解决

1.添加依赖到pom

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

2.修改启动类

@SpringBootApplication
public class xxxApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(xxxApplication.class);
    }

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

3.使用Intellij Idea

Build --> Build Artifacts --> 选择要打包编译的war --> 在项目target文件夹下出现新的war包

4.打包

猜你喜欢

转载自blog.csdn.net/csm0401/article/details/85092571