Firstly, I define my ApplicationListener in META-INF/spring.factories as folllows: SpringBoot Spring May Create An ApplicationListener with Class Annotated With @Component Twice Secondly, I annotate the ApplicationListener with Annotation @Component as follows: SpringBoot Spring May Create An ApplicationListener with Class Annotated With @Component Twice Thirdly, When I run my application, I get the following results: SpringBoot Spring May Create An ApplicationListener with Class Annotated With @Component Twice the output result shows that MyListener has been created twice, which has different reference, which results in this listener is called twice. Is this the expected result? Why a class annotated with @Component can still be instaniated twice. spring boot version: 2.5.2 my sample code : bug-test.zip

Comment From: snicoll

Yes it is the expected behavior. You are registering two components really, one using spring.factories and one by using classpath scanning and flagging the class as being a component. If you have further questions, please follow-up on StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Comment From: hyn1055543778

thank you