| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?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:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:task="http://www.springframework.org/schema/task"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
- http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
- http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
- <!-- 设置需要进行Spring注解扫描的类包 -->
- <context:component-scan base-package="com.happy" />
- <!-- 配置数据源 -->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <!--<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>-->
- <!--<property name="url" value="jdbc:mysql://192.168.161.220:3306/bigdata?useCursorFetch=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"></property>-->
- <!--<property name="password" value="root"></property>-->
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="jdbc:mysql://6.205.66.5:3306/bigdata?useCursorFetch=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"></property>
- <property name="password" value="Ro0!ot_369!"></property>
- <property name="username" value="root"></property>
- <!-- 配置获取连接等待超时的时间 -->
- <property name="maxWait" value="60000" />
- <property name="maxActive" value="20" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="90000" />
- <!-- 关闭长时间不使用的连接,防止连接池泄漏 -->
- <property name="removeAbandoned" value="true" />
- <!-- 打开removeAbandoned功能 -->
- <property name="removeAbandonedTimeout" value="600" /> <!-- 秒-->
- <property name="validationQuery" value="SELECT 'x'" />
- <property name="testWhileIdle" value="true" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <!-- 打开PSCache,并且指定每个连接上PSCache的大小(Oracle使用) -->
- <property name="poolPreparedStatements" value="true" />
- <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
- <!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
- <property name="filters" value="stat" />
- </bean>
- <!-- 配置Jdbc模板 -->
- <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate" scope="prototype">
- <constructor-arg ref="dataSource"></constructor-arg>
- </bean>
- <!-- 配置事务管理器 -->
- <bean id="transactionManager" scope="prototype"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
- <!-- 配置事务通知属性 -->
- <tx:advice id="txAdvice" transaction-manager="transactionManager" >
- <!-- 定义事务传播属性 -->
- <tx:attributes>
- <tx:method name="insert*" propagation="REQUIRED"/>
- <tx:method name="count*" propagation="REQUIRED"/>
- <tx:method name="update*" propagation="REQUIRED"/>
- <tx:method name="edit*" propagation="REQUIRED"/>
- <tx:method name="save*" propagation="REQUIRED"/>
- <tx:method name="add*" propagation="REQUIRED"/>
- <tx:method name="new*" propagation="REQUIRED"/>
- <tx:method name="set*" propagation="REQUIRED"/>
- <tx:method name="remove*" propagation="REQUIRED"/>
- <tx:method name="delete*" propagation="REQUIRED"/>
- <tx:method name="change*" propagation="REQUIRED"/>
- <tx:method name="get*" read-only="true" />
- <tx:method name="find*" read-only="true" />
- <tx:method name="load*" read-only="true" />
- <tx:method name="*" propagation="REQUIRED" />
- </tx:attributes>
- </tx:advice>
- <!-- 配置事务切面 -->
- <aop:config>
- <!-- 配置切点 -->
- <aop:pointcut id="serviceOperation"
- expression="execution(* com.happy.service.*.*(..))" />
- <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
- </aop:config>
- <!-- 配置定时任务 -->
- <task:annotation-driven />
- <task:scheduler id="dataScheduler" pool-size="5"/>
- </beans>
|