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