I'm trying to autowire a DAO that requires a String property. Here is the relevant part of the DAO implementation:
In my XML file, I define 'schemaName' with a property placeholder like so:Code:@Repository("accountDao") public class AccountDaoJdbcImpl implements AccountDao { private String schemaName; @Autowired public void setSchemaName(@Qualifier("schemaName") String schemaName) { this.schemaName = schemaName; } ... }
Now this by itself works great. No problems whatsoever. However, when I add an advisor to the ApplicationContext like so:Code:<bean id="schemaName" class="java.lang.String"> <constructor-arg value="${schemaName}" /> </bean>
...this appears to cause the 'schemaName' bean to no longer be of type java.lang.String. Instead it is now a proxy (as discovered while debugging). This causes an IllegalArgumentException when the setSchemaName(String schemaName) method is invoked on the DAO.Code:<aop:config> <aop:pointcut id="dao" expression="@target(org.springframework.stereotype.Repository)" /> <aop:advisor pointcut-ref="dao" advice-ref="daoAdvice" /> </aop:config>
First off, am I doing something wrong? If I am not, should I submit a JIRA for this?
For the record, I am doing the following component scan, and the bean is definitely getting included in the candidates. (I have various other DAO impls in the same package base, hence am excluding those).
Thanks in advance,Code:<context:component-scan base-package="com.my.company.daoimpl" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> <context:exclude-filter type="regex" expression=".*DaoMockImpl" /> <context:exclude-filter type="regex" expression=".*DaoHibernateImpl" /> </context:component-scan>
Jonathan


Reply With Quote
