修改方法
在pom.xml文件中添加下面的依赖:
<!--因配置外部TOMCAT 而配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
1
2
3
4
5
6
同时,将pom.xml文件首部的jar改成war
<groupId>com.star</groupId>
<artifactId>yiyong</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
1
2
3
4
5
6
最后,将启动类从
@SpringBootApplication
public class YiyongApplication {
public static void main(String[] args) {
SpringApplication.run(YiyongApplication.class, args);
}
}
1
2
3
4
5
6
7
修改为
@SpringBootApplication
public class YiyongApplication extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(YiyongApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(YiyongApplication.class, args);
}
}
java -jar jar名字
后台运行:
nohup java -jar 名字 &