Skip to content

Spring does not find all @ComponentScan or @PropertySource annotations #30941

Closed
@ladzar

Description

@ladzar

Affects: 6.0.11


When I compose my own annotations which all use @ComponentScan and I use those annotations on an application class, only the first one is used:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@ComponentScan(basePackageClasses = ModuleAClient.class)
public @interface ConnectedToModuleA {
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@ComponentScan(basePackageClasses = ModuleBClient.class)
public @interface ConnectedToModuleB {
}
@ConnectedToModuleA // Only the ComponentScan from this annotation is picked
@ConnectedToModuleB // ComponentScan from this annotation is ignored
public class MyApplication {

	public static void main(String[] args) {
		SpringApplication.run(MyApplication.class, args);
	}
}

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions