SpringBoot项目不占用端口启动

@EnableScheduling
@SpringBootApplication
public class Application {

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

 

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);
   }
}

 

 

 

posted @ 2018-08-11 10:28  wujf  阅读(6581)  评论(0)    收藏  举报