在下面的xml配置中,我有一个需要注入empDAO的sql查询。
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/conf/db.properties</value>
<value>/WEB-INF/conf/query.properties</value>
</list>
</property>
</bean>
<bean id="empDAO" class="com.dao.EmployeeDAO">
<!-- How to do Annotation-based autowire for the string-->
<property name="selectTradeQ" value="${select.emp}" />
</bean>
我的问题是如何使用字符串的Annotation-autowire?有些事情如下
//This is not possible ?? Then how to do this
<bean id="selectTradeQ" value="${select.emp}>
答案 0 :(得分:4)
@Component
public class EmployeeDAO {
@Value("${select.emp}")
private String selectTradeQ;
}