-
Aug 13th, 2012, 11:45 AM
#1
@Qualifier on constructor not working :(
Hi
I have two defined two datasources:
<beans ... default-autowire="byType">
...
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource" name="dataSource"> ...
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSourceXXX" name="dataSourceXXX"> ...
and want to inject one of them in an annotated StoredProcedure:
@Component
@Scope("prototype")
public class AddTrialProcedure extends StoredProcedure{
@Autowired
public AddTrialProcedure(@Qualifier("dataSource") DataSource dataSource) {
But Spring ignores @Qualifier and instead throws me an error on startup:
NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: [dataSource, dataSourceTrialpedia]
Where is the mistake?
Spring version is 3.1.2.RELEASE
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules