Step 1
添加
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 排除内置容器,排除内置容器导出成war包可以让外部容器运行spring-boot项目--> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
Step 2
启动类改成
@SpringBootApplication() @MapperScan(basePackages = "key.to.happiness.mapper") public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { builder.sources(this.getClass()); return super.configure(builder); } /** * Start */ public static void main(String[] args) { SpringApplication.run(Application.class, args); } }