DrMaemi / blog

1 stars 0 forks source link

[Spring Boot] 어플리케이션 실행 #183

Open DrMaemi opened 8 months ago

DrMaemi commented 8 months ago

@SpringBootApplication 어노테이션은 아래 세 어노테이션을 하나로 표현하기 위한 편의성 어노테이션일 뿐이다.

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {

        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("Let's inspect the beans provided by Spring Boot:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            Arrays.stream(beanNames).forEach(beanName -> System.out.println(beanName));
        };
    }
}

A. 참조

-"Building an Application with Spring Boot," spring.io