You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@Configuration classes are not enhanced with @ComponentScan [SPR-8069] #12724
I've tried to make use of spring's new features in 3.1 - namely @Profile and @ComponentScan
I have several profiles: test, dev and prod. (These creates embedded,basic or jndi datasources).
By using ComponentScan the classes annotated with @Configuration are not enhanced by cglib - so the @bean annotated methods are 'ignored' and not managed by container.
However - if I instead use @Import and explicitly specify the configuration classes - then they are properly enhanced.
Looking at documentation , 3.10.4 Defining bean metadata within components
"The @Bean methods in a Spring component are processed differently than their counterparts inside a Spring @Configuration class. The difference is that @Component classes are not enhanced with CGLIB to intercept the invocation of methods and fields. CGLIB proxying is the means by which invoking methods or fields within @Configuration classes @Bean methods create bean metadata references to collaborating objects. Methods are not invoked with normal Java semantics. In contrast, calling a method or field within a @Component classes @Bean method has standard Java semantics."
I would expect @Configuration classes to be enhanced when scanned as they are when they are imported.
Activity
spring-projects-issues commentedon Mar 23, 2011
Chris Beams commented
This indeed sounds like a bug. Thanks for the report, and we'll work it out by M2.
spring-projects-issues commentedon May 8, 2011
Chris Beams commented
The behavior described here is a side-effect of #12956. Please follow that issue to be notified of resolution.