I have something like this:
class MyBean {
@Autowired
@Qualifier("jdbcTemplate")
@BeanProperty
var jdbcTemplate : JdbcTemplate = null
}
Spring complains that it can't find a bean of type JdbcTemplate and refuses to autowire. My spring.xml has:
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg re开发者_C百科f="dataSource" />
</bean>
If I change the type of jdbcTemplate in MyBean from JdbcTemplate to SimpleJdbcTemplate then it works. My question is why is it apparently ignoring the Qualifier annotation? Am I doing something wrong?
It has nothing to do with @Qualifier
. SimpleJdbcTemplate
is not a subclass of JdbcTemplate
, therefore it cannot be injected into a field of type JdbcTemplate
.
精彩评论