Auto-configuration

To enable us to understand auto-configuration further, let's expand our application class to include a few more lines of code:

    ApplicationContext ctx = SpringApplication.run(Application.class,      args);    String[] beanNames = ctx.getBeanDefinitionNames();    Arrays.sort(beanNames);   for (String beanName : beanNames) {     System.out.println(beanName);    }

We get all the beans that are defined in the Spring application context and print their names. When Application.java is run as a Java program, it prints the list of beans, as shown in the following output :

applicationbasicErrorControllerbeanNameHandlerMappingbeanNameViewResolvercharacterEncodingFilterconventionErrorViewResolverdefaultServletHandlerMappingdefaultViewResolverdispatcherServlet ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.