1. 打包方式
- jar
- war
jar的方式比较简单,是springboot 默认的。
如果打包war, 部署到外部的tomcat, 需要做以下调整:
- 启动类
@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(WebApplication.class, args);
}
}
- pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupI