SpringBoot项目部署到外部Tomcat三部曲
一、配置pom.xml
在<project>
标签下加入
<packaging>war</packaging>
二、添加Tomcat模块
在<dependencies>
下添加
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
三、配置启动类
@SpringBootApplication public class InformApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(InformApplication.class); } public static void main(String[] args) { SpringApplication.run(InformApplication.class, args); } }
完成这三部曲就可以直接打成war包发布了。