代码之家  ›  专栏  ›  技术社区  ›  JPLauber

使用util:property路径作为注释的Spring属性

  •  1
  • JPLauber  · 技术社区  · 11 年前
    <bean id="groupContainerRelationshipDAO" class="containermanager.management.dao.GroupContainerRelationshipDAOImpl">
       <property name="dataSource">
          <util:property-path path="dataSourceFactory.dataSource" />
       </property>
    </bean>
    

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

    1 回复  |  直到 11 年前
        1
  •  1
  •   Artem Bilan    11 年前

    这个:

    @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