67,549
社区成员




<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
<bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc2.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc2.url}</value>
</property>
<property name="username">
<value>${jdbc2.username}</value>
</property>
<property name="password">
<value>${jdbc2.password}</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.connection.characterEncoding">utf8</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath*:/xx/xxx</value>
</list>
</property>
</bean>
<bean id="sessionFactory2" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.connection.characterEncoding">utf8</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath*:/xxx/xxxxx</value>
</list>
</property>
</bean>
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="jotm" />
</bean>
<!-- 属性文件读入 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
<!-- 支持 @Transactional 标记 -->
<tx:annotation-driven />
<!-- 支持 @AspectJ 标记-->
<aop:aspectj-autoproxy />
<!-- 以AspectJ方式 定义 AOP -->
<aop:config proxy-target-class="true">
<aop:advisor
pointcut="execution(* xx.xxx.xxxx..*Manager.*(..))"
advice-ref="txAdvice" />
<aop:advisor
pointcut="execution(* xx.xxx.xxxx.xxxxxxx.dao.*Dao.*(..))"
advice-ref="txAdvice" />
</aop:config>
<!-- 基本事务定义 -->
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<!-- 业务逻辑注入(只写了部分) -->
<bean id="testDao" class="xxxxxxxxxxxxxxxx.TestDAO">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="testService" class="xxxxxxxxxxxxxxxx.TestService">
<property name="testDao" ref="testDao" />
</bean>