Spring 3.0 has an annotation @Bean. It allows you to define a Spring bean directly in Java code. When I looked at the Spring link, I found two different ways to use this annotation: inside a class, annotated using @Configurationand inside a class that does not have this annotation.
This section contains the following code snippet:
@Component
public class FactoryMethodComponent {
@Bean @Qualifier("public")
public TestBean publicInstance() {
return new TestBean("publicInstance");
}
}
And here we could see a very similar piece of code, but now it @Configurationis in place:
@Configuration
public class AppConfig {
@Bean
public MyService myService() {
return new MyServiceImpl();
}
}
The previous section of the link contains the following explanation:
@Bean Spring , Spring @Configuration. , @Component CGLIB, . CGLIB - , @Configuration @Bean bean . Java. , @Component @Bean Java.
CGLIB - , ( , ). , Spring , @Bean Spring bean, .
, ?