springboot项目不占用端口启动

有些项目,如定时任务等,是不需要对外提供服务,也就不需要占用服务器端口的。那么,在SpringBoot项目中,怎么实现呢?其实很简单,如下:

1
2
3
4
5
6
7
8

@SpringBootApplication
public class {

public static void main(String[] args) {
new SpringApplicationBuilder().sources(Application.class).web(false).run(args);
}
}