<?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:tx="http://www.springframework.org/schema/tx"
|
xmlns:aop="http://www.springframework.org/schema/aop"
|
xmlns:context="http://www.springframework.org/schema/context"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
http://www.springframework.org/schema/tx
|
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
|
http://www.springframework.org/schema/aop
|
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
default-lazy-init="true"
|
>
|
<description>Spring公共配置文件</description>
|
<context:component-scan base-package="com.yc"/>
|
<context:component-scan base-package="me.chanjar"/>
|
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
|
<context:annotation-config/>
|
<import resource="spring-redis.xml"/>
|
<!--
|
<context:property-placeholder location="classpath:jdbc.properties"/>
|
-->
|
|
<!--
|
****************************代理connection用当前线程记录执行sql配置start**********************************
|
-->
|
<!--配置统一数据源,将来系统中使用的数据源将从他当中获取-->
|
<bean id="multiDataSource" class="com.yc.multiData.MultiDataSource"></bean>
|
<!--封装dataSource 对当前线程所执行的sql进行记录-->
|
<bean id="dataSource" class="com.yc.dataAccess.YCDataSource">
|
<constructor-arg name="dataSource">
|
<ref bean="multiDataSource"/>
|
</constructor-arg>
|
</bean>
|
<!--
|
****************************记录执行sql配置end**********************************
|
-->
|
<!--
|
****************************不使用代理connection(不记录执行sql配置start)**********************************
|
-->
|
<!--
|
****************************不记录执行sql配置end**********************************
|
-->
|
<!-- 配置defaultLobHandler -->
|
<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"
|
lazy-init="true"/>
|
<!-- 基本的JDBC操作类,在server层直接引用就可以使用 -->
|
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<!-- 提供用javaBean作为对象进行参数传递给jdbc使用,在server层直接引用就可以使用 -->
|
<bean id="simpleJdbcInsert" class="org.springframework.jdbc.core.simple.SimpleJdbcInsert">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<!-- 提供用命令参数进行参数传递给jdbc使用,在server层直接引用就可以使用 -->
|
<bean id="namedParameterJdbcTemplate"
|
class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<!-- 提供调用存储过程功能给jdbc使用,在server层直接引用就可以使用 -->
|
<bean id="simpleJdbcCall" class="org.springframework.jdbc.core.simple.SimpleJdbcCall">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<!--19类型存储过程调用-->
|
<bean id="simpleJdbcCallByProc" class="org.springframework.jdbc.core.simple.SimpleJdbcCall">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<bean id="simpleJdbcCallShopping" class="org.springframework.jdbc.core.simple.SimpleJdbcCall" scope="prototype">
|
<constructor-arg name="dataSource">
|
<ref bean="dataSource"/>
|
</constructor-arg>
|
</bean>
|
<!-- 事务管理 -->
|
<bean id="transactionManager"
|
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
<property name="dataSource">
|
<ref bean="dataSource"/>
|
</property>
|
</bean>
|
<!-- 定义事务通知-->
|
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
<tx:attributes>
|
<tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="new*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="create*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="change*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="do*" propagation="REQUIRED" rollback-for="Exception"/>
|
<tx:method name="addErrorLog" propagation="NOT_SUPPORTED"/>
|
<tx:method name="excelRecord" propagation="NOT_SUPPORTED"/>
|
<tx:method name="*" propagation="SUPPORTS" read-only="true"/>
|
</tx:attributes>
|
</tx:advice>
|
<!-- 事物,日志(拦截service包的所有执行sql函数对执行sql报错的保存到数据库)AOP配置-->
|
<aop:config>
|
<aop:pointcut id="bizMethods"
|
expression="execution(* com.yc.service..*.*(..)) or execution(* com.yc.sdk.shopping.service..*.*(..)) or execution(* com.yc.sdk.weixincp.service..*.*(..)) or execution(* com.yc.sdk.weixinmp.service..*.*(..)) or execution(* com.yc.api.service..*.*(..)) or execution(* com.yc.ionic.service..*.*(..)) or execution(* com.yc.sdk.oauth2.service..*.*(..)) or execution(* com.yc.im.service..*.*(..)) or execution(* com.yc.batchUpload.service..*.*(..)) or execution(* com.yc.MaintenanceFee.service..*.*(..))"/>
|
<aop:pointcut id="logger"
|
expression="(execution(* com.yc.service..*.*(..)) or execution(* com.yc.sdk.shopping.service..*.*(..)) or execution(* com.yc.sdk.weixincp.service..*.*(..)) or execution(* com.yc.sdk.weixinmp.service..*.*(..)) or execution(* com.yc.api.service..*.*(..)) or execution(* com.yc.app.v2.service..*.*(..)) or execution(* com.yc.ionic.service..*.*(..)) or execution(* com.yc.sdk.oauth2.service..*.*(..)) or execution(* com.yc.im.service..*.*(..)) or execution(* com.yc.batchUpload.service..*.*(..)) or execution(* com.yc.MaintenanceFee.service..*.*(..)) ) and !execution(* com.yc.service.log.ErrorLogImpl.*(..))"/>
|
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods"/>
|
<aop:aspect id="loggerAspect" ref="genericLoggerBean">
|
<aop:around pointcut-ref="logger" method="invoke"/>
|
</aop:aspect>
|
</aop:config>
|
<!-- 事物,日志AOP配置-->
|
<!-- 事物,不进行日志AOP配置-->
|
<!--
|
<aop:config> <aop:pointcut id="bizMethods" expression="execution(*
|
com.yc.service..*.*(..))" /> <aop:advisor advice-ref="txAdvice"
|
pointcut-ref="bizMethods" /> </aop:config>
|
-->
|
<!-- 事物,不进行日志AOP配置-->
|
<bean id="genericLoggerBean" class="com.yc.log.ErrorLoggerBean"></bean>
|
<!-- 使用annotation定义事务 -->
|
<tx:annotation-driven/>
|
<!--
|
****************************国际化**********************************
|
-->
|
<!-- 这个 bean的id是规定死的,只能为messageSource -->
|
<bean id="messageSource"
|
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
|
<property name="basenames">
|
<list>
|
<value>messageSource/messages</value>
|
</list>
|
</property>
|
</bean>
|
<!--
|
****************************国际化**********************************
|
-->
|
<!-- 重新生成功能号 -->
|
<bean id="formidVersion" class="com.yc.action.build.FormidVersion">
|
<property name="formidConfig">
|
<value>classpath:FormidVersion.xml</value>
|
</property>
|
</bean>
|
</beans>
|