Gabriel Bauman
Gabriel Bauman

Reputation: 2416

How can I list all beans annotated with @Configuration in an application context?

How can I get a list of all active @Configuration beans from an application context so I can list them at startup?

Upvotes: 1

Views: 134

Answers (1)

Jonathan JOhx
Jonathan JOhx

Reputation: 5968

You can call the application context and ask it by all beans annotated with @Configuration annotation, make sure you call once only the ApplicationContext instance, and not call it several times, then you can ask by beans with that annotation by following this:

Map<String, Object> beans = applicationContext.getBeansWithAnnotation(Configuration.class);

Upvotes: 1

Related Questions