fs-danaus
2024-09-10 05aec6b35a58057856c8b56428f2a9f127c958f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?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>