Commit 54eb6ae7 authored by wangjinjing's avatar wangjinjing

更新springbase 文件

parent 855f0cd6
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:cxf="http://cxf.apache.org/core" xmlns:cxf="http://cxf.apache.org/core"
xmlns:simple="http://cxf.apache.org/simple" xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<!-- enable spring annotation scan --> <!-- enable spring annotation scan -->
<context:annotation-config/> <context:annotation-config/>
<context:component-scan base-package="cn.bsystem.*" /> <context:component-scan base-package="cn.bsystem.*" />
...@@ -23,84 +23,126 @@ ...@@ -23,84 +23,126 @@
<context:component-scan base-package="cn.map.*" /> <context:component-scan base-package="cn.map.*" />
<context:component-scan base-package="cn.yw.*" /> <context:component-scan base-package="cn.yw.*" />
<context:component-scan base-package="cn.nhyw.*" /> <context:component-scan base-package="cn.nhyw.*" />
<!-- <!--
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"> <property name="location">
<value>classpath:init.properties</value> <value>classpath:init.properties</value>
</property> </property>
</bean> </bean>
--> -->
<bean id="beanUtil" class="cn.base.bean.BeanHelper"></bean> <bean id="beanUtil" class="cn.base.bean.BeanHelper"></bean>
<bean id="aspectService" class="cn.base.aspect.OperateAspect"></bean> <bean id="aspectService" class="cn.base.aspect.OperateAspect"></bean>
<bean id="moduleConfFactory" class="cn.base.conf.ModuleConfFactory"></bean> <bean id="moduleConfFactory" class="cn.base.conf.ModuleConfFactory"></bean>
<bean class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" id="dataSource"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="driverClassName">
<value>oracle.jdbc.OracleDriver</value> <property name="locations" value="classpath:db.properties"/>
</property>
<!-- <property name="url">--> </bean>
<!-- <value>jdbc:oracle:thin:@10.10.10.200:1521:orcl</value>-->
<!-- </property> --> <bean id="dataSourceAspect" class="cn.datasource.DynamicDataSourceAspect" />
<!-- <property name="username">-->
<!-- <value>oa01</value>--> <!-- 数据源1-->
<!-- </property>-->
<!-- <property name="password">--> <bean id="datasource1" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<!-- <value>oaoaoa7</value>-->
<!-- </property>--> <property name="driverClassName" value="${datasource1.driver}"/>
<property name="url"> <property name="url" value="${datasource1.url}"/>
<value>jdbc:oracle:thin:@61.155.110.210:7001:orcl</value>
</property> <property name="username" value="${datasource1.username}"/>
<property name="username">
<value>IMP</value> <property name="password" value="${datasource1.password}"/>
</property>
<property name="password"> <property name="initialSize" value="${jdbc.initialSize}"/>
<value>imp</value>
</property> <property name="minIdle" value="${jdbc.minIdle}"/>
<property name="initialSize">
<value>5</value> <property name="maxIdle" value="${jdbc.maxIdle}"/>
</property>
<property name="minIdle"> <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>
<value>5</value>
</property> <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>
<property name="maxIdle">
<value>20</value> <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>
</property>
<property name="maxTotal"> <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>
<value>30</value>
</property> <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>
<property name="removeAbandonedOnBorrow">
<value>true</value>
</property> </bean>
<property name="removeAbandonedTimeout">
<value>60</value> <!-- 数据源2-->
</property>
<property name="logAbandoned"> <bean id="datasource2" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<value>true</value>
<property name="driverClassName" value="${datasource2.driver}"/>
<property name="url" value="${datasource2.url}"/>
<property name="username" value="${datasource2.username}"/>
<property name="password" value="${datasource2.password}"/>
<property name="initialSize" value="${jdbc.initialSize}"/>
<property name="minIdle" value="${jdbc.minIdle}"/>
<property name="maxIdle" value="${jdbc.maxIdle}"/>
<property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>
<property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>
<property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>
<property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>
<property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>
</bean>
<!-- 配置动态配置数据源 -->
<bean id ="dynamicDataSource" class= "cn.datasource.DynamicDataSource">
<!-- 默认使用dataSource1的数据源 -->
<property name ="defaultTargetDataSource" ref="datasource1"></property>
<property name ="targetDataSources">
<map key-type ="java.lang.String">
<entry key= "datasource1" value-ref="datasource1"></entry>
<entry key= "datasource2" value-ref="datasource2"></entry>
</map>
</property> </property>
</bean> </bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"> <property name="configLocation">
<value>classpath:sqlMapConfig.xml</value> <value>classpath:sqlMapConfig.xml</value>
</property> </property>
<property name="dataSource"> <property name="dataSource">
<ref bean="dataSource" /> <ref bean="dynamicDataSource" />
</property> </property>
<!-- <property name="lobHandler"><ref local="oracleLobHandler"/></property> --> <!-- <property name="lobHandler"><ref local="oracleLobHandler"/></property> -->
</bean> </bean>
<!-- <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"></bean> --> <!-- <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"></bean> -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"> <property name="dataSource">
<ref local="dataSource" /> <ref local="dynamicDataSource" />
</property> </property>
</bean> </bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes> <tx:attributes>
<tx:method name="get*" read-only="true" /> <tx:method name="get*" read-only="true" />
...@@ -108,22 +150,33 @@ ...@@ -108,22 +150,33 @@
</tx:attributes> </tx:attributes>
</tx:advice> </tx:advice>
<context:annotation-config />
<aop:aspectj-autoproxy proxy-target-class="true"/>
<aop:config>
<!-- 动态数据源切割 -->
<aop:aspect id="dynamicAspect" ref="dataSourceAspect" >
<aop:pointcut id="pointCut" expression="execution(* cn.*.service.*.*(..))" />
<aop:after pointcut-ref="pointCut" method="afterSwitchDS"/>
<aop:before pointcut-ref="pointCut" method="beforeSwitchDS"/>
</aop:aspect>
</aop:config>
<aop:config> <aop:config>
<aop:pointcut id="netmanagerServiceOperation" expression="bean(*Service)" /> <aop:pointcut id="netmanagerServiceOperation" expression="bean(*Service)" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="netmanagerServiceOperation" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="netmanagerServiceOperation" />
</aop:config> </aop:config>
<aop:aspectj-autoproxy proxy-target-class="true"/> <aop:config>
<aop:config>
<aop:aspect id="operateAspect" ref="aspectService"> <aop:aspect id="operateAspect" ref="aspectService">
<aop:pointcut expression="execution(* cn.im.*.action.*Action.*(..)) or execution(* cn.bsystem.*.action.*Action.*(..))" id="logPointcut"/> <aop:pointcut expression="execution(* cn.im.*.action.*Action.*(..)) or execution(* cn.bsystem.*.action.*Action.*(..))" id="logPointcut"/>
<aop:before pointcut-ref="logPointcut" method="before"/> <aop:before pointcut-ref="logPointcut" method="before"/>
<aop:around pointcut-ref="logPointcut" method="doAround"/> <aop:around pointcut-ref="logPointcut" method="doAround"/>
<aop:after-throwing pointcut-ref="logPointcut" method="afterThrow" throwing="ex"/> <aop:after-throwing pointcut-ref="logPointcut" method="afterThrow" throwing="ex"/>
</aop:aspect> </aop:aspect>
</aop:config> </aop:config>
<import resource="springService.xml" /> <import resource="springService.xml" />
</beans> </beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment