1 are packaged into the WAR, because if it is java -jar xx.jar
run, it must be jar package
<packaging>war</packaging>
2. Add rely tomcat, but pay attention to the scope (scope)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootApplication.class);
}
}
4. tomcat8 above, experience: with tomcat7 and below, will be reported the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path