环境:jdk13,tomcat9,ubuntu19.10
工具:idea
注意:因自jdk11之后取消jre,所以配置jdk环境变量,JRE_HOME=$JAVA_HOME,否则tomcat无法启动
pom.xml修改:注意这两项<packaging>war</packaging>,<finalName>demo</finalName>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
</parent>
<build>
<finalName>demo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
启动类修改:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
运行maven install打包,并将war拷贝到tomcat下