1、首先在Maven依赖中添加依赖;
|
注:SpringBoot默认是内嵌tomcat,现在因为要放到独立的tomcat中运行,原内嵌的tomcat就不需要了,所以在Maven中添加spring-boot-starter-tomcat并设置为provided,这样打包的时候会把这个依赖排除;
3、SpringBoot 入口类【Application】,需要继承【SpringBootServletInitializer】,并重写【configure】方法;
@SpringBootApplication(scanBasePackages={"com.andy"})
public class Application extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
4、然后把项目添加到tomcat中运行即可。