<!-- 数据源(主库) -->                        
        <bean id="dataSource_main" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <property name="driverClass" value="${jdbc.driverclass}" />
            <property name="jdbcUrl" value="${jdbc.url}" />
            <property name="user" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
            
            <property name="maxPoolSize" value="${c3p0.pool.size.max}" />
            <property name="minPoolSize" value="${c3p0.pool.size.min}" />
            <property name="initialPoolSize" value="${c3p0.pool.size.ini}" />
            <property name="acquireIncrement" value="${c3p0.pool.size.increment}" />
        </bean>
        
        <!-- 数据源(从库) -->                        
        <bean id="dataSource_1" parent="dataSource_main">
            <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/lsn_surveypark0909_1" />
        </bean>
        
        
        <!-- 数据源路由器 -->
        <bean id="dataSource_router" class="cn.itcast.surveypark.datasource.SurveyparkDataSourceRouter">
            <property name="targetDataSources">
                <map>
                    <entry key="odd" value-ref="dataSource_main" />
                    <entry key="even" value-ref="dataSource_1" />
                </map>
            </property>
            <property name="defaultTargetDataSource" ref="dataSource_main" />
        </bean>
    <!-- aop事务配置 -->
        <aop:config>
            <!-- 事务切入点 -->
            <aop:pointcut expression="execution(* *..*Service.*(..))" id="txPointcut"/>
            <!-- 日志切入点 -->
            <aop:pointcut expression="(execution(* *..*Service.save*(..))
                                    or execution(* *..*Service.update*(..))
                                    or execution(* *..*Service.delete*(..))
                                    or execution(* *..*Service.batch*(..))
                                    or execution(* *..*Service.new*(..))) and !bean(logService)" 
                        id="loggerPointcut"/>
            
            <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" order="1"/>
            
            <!-- 配置日志切面 -->
            <aop:aspect id="loggerAspect" ref="logger" order="0">
                <aop:around method="record" pointcut-ref="loggerPointcut"/>
            </aop:aspect>
        </aop:config>
aop

相关文章:

  • 2021-11-16
  • 2021-10-28
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-25
  • 2021-12-19
  • 2022-01-08
猜你喜欢
  • 2021-09-17
  • 2022-02-20
  • 2021-11-24
  • 2021-07-10
  • 2021-07-24
  • 2021-08-02
  • 2021-06-16
相关资源
相似解决方案