instructions → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
instructions → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
XML → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
XML → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
┌─────────────────────┐ <namespace:*> → │ the Spring container│ XML └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
scanning → │ the Spring container│ + @Autowired └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
scanning → │ the Spring container│ + @Autowired └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
+ @Bean → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
main(String... args) { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); // retrieve the bean we want to use in typesafe fashion QuoteService quoteService = ctx.getBean(QuoteService.class); System.out.println(quoteService.currentValue("AAPL")); } }
is definitely not going anywhere. This is a concern that commonly comes up when we talk about annotations and such, but we've said it before and we'll say it again: XML was, is, and ever will be a first class citizen in Spring. These new features just mean that if you don't want XML, you don't have to use it. That's all. kthx, bye.
+ @Bean → │ the Spring container│ └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
+ @Bean → │ the Spring container│ + @Enable* └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘
+ ┌─────────────────────┐ @Component + → │ the Spring container│ @Configuration └─────────────────────┘ ┌─────────────────────────┐ │ fully configured system │ │ ready for use │ └─────────────────────────┘