开发者

Spring 3.0 Annonation-based AutoWiring

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜