【发布时间】:2018-01-25 21:06:41
【问题描述】:
我有一些完全相同的 SQL 查询,但用于我的 bean XML 中的不同 bean ids/classes。您可以创建一个不绑定到特定 bean 的属性,并根据需要将其注入到 bean id 中吗?
以下只是两个不同 bean 中两个确切属性的示例。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="regionalPage" class="com.test.RegionalPageDao">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="activeList">
<value><![CDATA[select * from regionalTable]]></value>
</property>
</bean>
<bean id="regionalBackup" class="com.test.RegionalPageBackupDao">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="activeList">
<value><![CDATA[select * from regionalTable]]></value>
</property>
</bean>
</beans>
【问题讨论】:
标签: spring