SpringBoot: 使用外置Tomcat部署
作者:互联网
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <!--增加JVM参数--> <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> <!--指定入口类--> <mainClass>cc.jamb.AmpersandApplication</mainClass> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin>
server: port: 6060 # VM: -Dserver.port=6060 Program: --server.port=6060 使用外部容器部署, 失效 servlet: context-path: /ampersand # 使用外部容器部署, 失效
启动类
// SpringBootServletInitializer: 不使用内嵌容器启动, 使用外部tomcat启动 @SpringBootApplication public class AmpersandApplication extends SpringBootServletInitializer{ public static void main(String[] args){ for(String arg : args){ System.out.println("arg = " + arg); } String port = System.getProperty("server.port"); System.out.println("port = " + port); SpringApplication.run(AmpersandApplication.class, args); } @Override // 配置入口类 protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){ return builder.sources(AmpersandApplication.class); } }
标签:AmpersandApplication,SpringBoot,Tomcat,System,外置,6060,arg,port,String 来源: https://www.cnblogs.com/dissipate/p/16197052.html