DEV Community

Mac
Mac

Posted on

Spring Boot : Setup non-web app

If you have spring-boot-starter-web in pom.xml

@Slf4j
@SpringBootApplication
public class App implements CommandLineRunner {

    public static void main( String[] args ) {
        SpringApplication springApplication = new SpringApplication(App.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info("Hello World");
    }
}

If you have spring-boot-starter in pom.xml

@Slf4j
@SpringBootApplication
public class App implements CommandLineRunner {

    public static void main( String[] args ) {
        SpringApplication.run(App.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info("Hello World");
    }
}

Top comments (0)