Skip to content

@Configuration classes are not enhanced with @ComponentScan [SPR-8069] #12724

Closed
@spring-projects-issues

Description

@spring-projects-issues

Magnus Kvalheim opened SPR-8069 and commented

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.


Affects: 3.1 M1

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions