How to use `javax.inject.Qualifier` to get bean in spring application context?

807 Views Asked by At

JSR-330 provide @Qualifier to qualifies beans. For example, define the following qualifier annotation.

@Qualifier
@interface Category{
  String value();
}

and use it like this

@Bean
@Category("simple")
SomeThing get(){
  return ...
}

@Inject
@Category("simple")
SomeThing sth;

It does work.

But how can I get the bean from ApplicationContext?

ApplicationContext context
context... // how to get the @Category("simple") bean
0

There are 0 best solutions below