开发者

Spring 3.0 Annonation-based AutoWiring

开发者 https://www.devze.com 2023-04-11 03:41 出处:网络
In the below xml configuartion, i have a sql query which needs to be injected to empDAO. <bean id=\"propertyPlaceholderConfigurer\"

In the below xml configuartion, i have a sql query which needs to be injected to empDAO.

<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>

My question is How to use Annotation-autowire for the String? Some thing 开发者_如何学Clike below

 //This is not possible ?? Then how to do this
    <bean id="selectTradeQ" value="${select.emp}> 


@Component
public class EmployeeDAO {
  @Value("${select.emp}")
  private String selectTradeQ;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号