spring boot 2.x 不占用端口方式启动
当我们通过spring boot 仅运行一些定时任务时,就可以不用占用web启动端口,这时候就需要spring boot 不占用web端口的方式;
springboot 2.x之后(代码方式)
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(MyApplication.class)
.web(WebApplicationType.NONE) // .REACTIVE, .SERVLET
.run(args);
}
}
springboot 2.x之后(配置方式)
spring.main.web-application-type=none
参考:https://www.cnblogs.com/angryprogrammer/p/11757302.html