使用util:property-path作为注释的Spring属性

时间:2014-08-04 11:37:18

标签: java spring dao

<bean id="groupContainerRelationshipDAO" class="containermanager.management.dao.GroupContainerRelationshipDAOImpl">
   <property name="dataSource">
      <util:property-path path="dataSourceFactory.dataSource" />
   </property>
</bean>

我想将此定义为spring注释。问题是dataSource是继承类SimpleJdbcDaoSupport的成员。有人知道怎么做吗?

1 个答案:

答案 0 :(得分:1)

这一个:

@Component
class GroupContainerRelationshipDAOImpl {

  @Value("#{dataSourceFactory.dataSource}")
  private DataSource dataSource;

}

详细了解@Value注释:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-annotation-config