81,092
社区成员
发帖
与我相关
我的任务
分享
<!-- 配置数据源,使用proxool连接池 -->
<bean id="dataSource1" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>${database.driver1}</value>
</property>
<property name="driverUrl">
<value>${database.url1}</value>
</property>
<property name="user">
<value>${database.username1}</value>
</property>
<property name="password">
<value>${database.password1}</value>
</property>
<property name="alias">
<value>MyPool1</value>
</property>
<property name="prototypeCount">
<value>10</value>
</property>
<property name="minimumConnectionCount">
<value>10</value>
</property>
<property name="maximumConnectionCount">
<value>50</value>
</property>
<property name="houseKeepingSleepTime">
<value>30000</value>
</property>
<property name="maximumActiveTime">
<value>180000</value>
</property>
<property name="maximumConnectionLifetime">
<value>3600000</value>
</property>
<property name="trace">
<value>false</value>
</property>
<property name="verbose">
<value>false</value>
</property>
</bean>
<bean id="dataSource2" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>${database.driver2}</value>
</property>
<property name="driverUrl">
<value>${database.url2}</value>
</property>
<property name="user">
<value>${database.username2}</value>
</property>
<property name="password">
<value>${database.password2}</value>
</property>
<property name="alias">
<value>MyPool2</value>
</property>
<property name="prototypeCount">
<value>10</value>
</property>
<property name="minimumConnectionCount">
<value>10</value>
</property>
<property name="maximumConnectionCount">
<value>50</value>
</property>
<property name="houseKeepingSleepTime">
<value>30000</value>
</property>
<property name="maximumActiveTime">
<value>180000</value>
</property>
<property name="maximumConnectionLifetime">
<value>3600000</value>
</property>
<property name="trace">
<value>false</value>
</property>
<property name="verbose">
<value>false</value>
</property>
</bean>
<!-- 配置ibatis -->
<bean id="sqlMapClient1" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource1" />
<property name="configLocation">
<value>classpath:sqlmap-config1.xml</value>
</property>
</bean>
<bean id="sqlMapClient2" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="configLocation">
<value>classpath:sqlmap-config2.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate1" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient1" />
</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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="userBeanTest" class="com.zhangyz.tools.UserBeanTest"
scope="prototype" />
<bean id="springInterceptor" class="com.zhangyz.tools.SpringInterceptor"></bean>
<aop:config>
<aop:aspect ref="springInterceptor">
<aop:pointcut expression="execution(* com.zhangyz.tools..*method1(..))"
id="method1" />
<aop:around method="aroundMethod" pointcut-ref="method1" />
</aop:aspect>
</aop:config>
<bean id="propertyAutoChange"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource1" class="com.ibatis.common.jdbc.SimpleDataSource">
<constructor-arg index="0">
<map>
<entry>
<key>
<value>JDBC.DefaultAutoCommit</value>
</key>
<value>${jdbc.autoCommit}</value>
</entry>
<entry>
<key>
<value>JDBC.Driver</value>
</key>
<value>${jdbc.driverClassName}</value>
</entry>
<entry>
<key>
<value>JDBC.ConnectionURL</value>
</key>
<value>${jdbc.url}</value>
</entry>
<entry>
<key>
<value>JDBC.Username</value>
</key>
<value>${jdbc.username}</value>
</entry>
<entry>
<key>
<value>JDBC.Password</value>
</key>
<value>${jdbc.password}</value>
</entry>
</map>
</constructor-arg>
</bean>
<bean id="dataSource2" class="com.ibatis.common.jdbc.SimpleDataSource">
<constructor-arg index="0">
<map>
<entry>
<key>
<value>JDBC.DefaultAutoCommit</value>
</key>
<value>${jdbc.autoCommit}</value>
</entry>
<entry>
<key>
<value>JDBC.Driver</value>
</key>
<value>${jdbc.driverClassName}</value>
</entry>
<entry>
<key>
<value>JDBC.ConnectionURL</value>
</key>
<value>${jdbc.url}</value>
</entry>
<entry>
<key>
<value>JDBC.Username</value>
</key>
<value>${jdbc.username}</value>
</entry>
<entry>
<key>
<value>JDBC.Password</value>
</key>
<value>${jdbc.password}</value>
</entry>
</map>
</constructor-arg>
</bean>
<bean id="sqlMapClient1" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource1"></property>
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClient2" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource2"></property>
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate1" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient1"></property>
</bean>
<bean id="sqlMapClientTemplate2" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient2"></property>
</bean>
<bean id="accountDao1" class="com.zhangyz.dao.impl.AccountDaoImpl">
<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate1"></property>
</bean>
<bean id="accountDao2" class="com.zhangyz.dao.impl.AccountDaoImpl">
<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate2"></property>
</bean>
<bean id="accountService" class="com.zhangyz.service.AccountService">
<property name="accountDao1" ref="accountDao1"></property>
<property name="accountDao2" ref="accountDao2"></property>
</bean>
<bean id="accountAction" class="com.zhangyz.action.AccountAction">
<property name="accountService" ref="accountService"></property>
</bean>
</beans>
public final void setSqlMapClient(SqlMapClient sqlMapClient) {
if (!this.externalTemplate) {
this.sqlMapClientTemplate.setSqlMapClient(sqlMapClient);
}
}
public final void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
Assert.notNull(sqlMapClientTemplate, "SqlMapClientTemplate must not be null");
this.sqlMapClientTemplate = sqlMapClientTemplate;
this.externalTemplate = true;
}
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="dataSourceSysadmin"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@192.168.0.111:1521:ORCL" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="dataSysadmin"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@192.168.0.111:1521:ORCL" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSysadmin" />
</bean>
<aop:config>
<aop:advisor
pointcut="execution(* com.aisino2..service.*.*(..))"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" />
<tx:method name="delete*" />
<tx:method name="update*" />
<tx:method name="uploadFkxx*" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="classpath:config/ibatis/sql-map-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlMapSysadmin"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"
value="classpath:config/ibatis/oracle/sql-map-sysadmin-config.xml" />
<property name="dataSource" ref="dataSysadmin" />
</bean>
<bean id="operateLog"
class="com.aisino2.sysadmin.dao.OperateLogNote">
<property name="sqlMapClient" ref="sqlMapSysadmin" />
</bean>
</beans>