I wonder if there is a way in Spring to know what configuration triggers creation of a particular bean? So the case is the following: there are some @Configuration
marked classes, some of them may be also annotated with @ComponentScan
annotation. How can I figure out which of this configurations triggers creation of a particular bean? I mean triggers processing @Component
annotation, only this case.
Thanks for any thoughts in advance!
Asked
Active
Viewed 35 times
0

Dmitry Senkovich
- 5,521
- 8
- 37
- 74
-
The `@Configuration` classes don't create beans, unless you're talking about `@Bean` annotated methods. They just supply the `@ComponentScan` information to the Spring framework, which does the actual scanning and bean creation, including the creation of the `@Configuration` beans themselves. – Andreas Apr 24 '17 at 22:48
-
@Andreas I understand it. Spring processes the `@Configuration` annotation, searches for `@Component` annotated classes if needed and creates beans. But it is a configuration class that triggers this search as far as I understand. Just to make it more clear: I'm working on a maven plugin. – Dmitry Senkovich Apr 24 '17 at 22:51
-
Correct, but that is not how your question is phrased: *"How can I figure out which of this configurations creates a particular bean?"* The configuration doesn't *create* the beans. Edit and clarify your question if that is not what you intended to ask. – Andreas Apr 24 '17 at 22:53
-
@Andreas Thanks for the note, I've edited the question. – Dmitry Senkovich Apr 24 '17 at 23:06