亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

SpringBoot項(xiàng)目不占用端口啟動的方法

 更新時間:2018年08月16日 10:55:33   作者:Jetyang  
這篇文章主要介紹了SpringBoot項(xiàng)目不占用端口啟動的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

SpringBoot項(xiàng)目不占用端口啟動

現(xiàn)在很多互聯(lián)網(wǎng)公司或者項(xiàng)目,都使用SpringBoot + SpringCloud,以微服務(wù)的形式來提供后臺服務(wù)。而且既然是微服務(wù),所涉及到的項(xiàng)目就會很多,服務(wù)器端口資源就會相當(dāng)緊張。而且,其實(shí)有些項(xiàng)目,如定時任務(wù)等,是不需要對外提供服務(wù),也就不需要占用服務(wù)器端口的。那么,在SpringBoot項(xiàng)目中,怎么實(shí)現(xiàn)呢?其實(shí)很簡單,如下:

@EnableScheduling
@SpringBootApplication
public class Application {

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

這樣,項(xiàng)目可以正常啟動,而且,這個項(xiàng)目是不占用端口的。一般適用于定時任務(wù)項(xiàng)目。

Starting from Spring Boot 2.0

-web(false)/setWebEnvironment(false) is deprecated and instead Web-Application-Type can be used to specify
spring.main.web-application-type=NONE

@SpringBootApplication
public class SpringBootDisableWebEnvironmentApplication {

  public static void main(String[] args) {
    new SpringApplicationBuilder(SpringBootDisableWebEnvironmentApplication .class)
      .web(WebApplicationType.NONE) // .REACTIVE, .SERVLET
      .run(args);
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論