Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring: Using @Qualifier with Property Placeholder

Tags:

spring

I am trying to use a property placeholder as the attribute for @Qualifier, as follows:

@Autowired
@Qualifier("${beanName}")
private MyBean myBean;

However, this does not work, even though the property placeholder is available as a String value:

@Value("${beanName}")
private String beanName;

What would be a good workaround here, thanks very much.

like image 696
user1052610 Avatar asked Aug 13 '13 12:08

user1052610


1 Answers

I encountered exactly same issue. Just use Resource

@Resource(name="${beanName}")
private MyBean myBean;
like image 55
Gaurav Kumar Gupta Avatar answered Nov 09 '22 02:11

Gaurav Kumar Gupta