<?xml version="1.0" encoding="UTF-8"?>java
<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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"spring
xsi:schemaLocation=" http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd 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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> <task:annotation-driven /> <!-- 定時器開關 --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- 自動加載構建bean --> <context:component-scan base-package="com.huawei.service" /> <context:component-scan base-package="com.huawei.dao" /> <context:component-scan base-package="com.huawei.timer"></context:component-scan> <!-- 配置數據源 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="filters" value="stat" /> <property name="maxActive" value="8" /> <property name="initialSize" value="2" /> <property name="maxWait" value="30" /> <property name="minIdle" value="4" /> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <property name="minEvictableIdleTimeMillis" value="300000" /> <property name="validationQuery" value="SELECT 'x'" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="maxOpenPreparedStatements" value="20" /> <property name="removeAbandoned" value="true" /> <!-- 打開removeAbandoned功能 --> <property name="removeAbandonedTimeout" value="1800" /> <!-- 1800秒,也就是30分鐘 --> <property name="logAbandoned" value="true" /> <!-- 關閉abanded鏈接時輸出錯誤日誌 --> </bean> <!-- 配置Jdbc模板 --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 配置事務管理器 --> <bean id="transactionManager" 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*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="load*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" propagation="REQUIRED" read-only="true" /> </tx:attributes> </tx:advice> <!-- 配置事務切面 --> <aop:config> <aop:pointcut id="serviceOperation" expression="execution(* com.huawei.service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" /> </aop:config> <bean id="dao" class="com.huawei.util.Dao" /> <bean id="exampleBean" class="com.huawei.util.Demo"> <property name="name" value="explenBeanName" /> <property name="dao" ref="dao" /> </bean> <context:component-scan base-package="com.huawei.util" /> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="${host}" /> <property name="port" value="${port}" /> <property name="username" value="yanl_07@163.com" /> <property name="password" value="905281577yl" /> <property name="javaMailProperties"> <props> <!-- Use SMTP transport protocol --> <prop key="mail.transport.protocol">${protocol}</prop> <!-- Use SMTP-AUTH to authenticate to SMTP server --> <prop key="mail.smtp.auth">${auth}</prop> <!-- Use TLS to encrypt communication with SMTP server --> <prop key="mail.smtp.starttls.enable">${enable}</prop> <prop key="mail.debug">false</prop> </props> </property> </bean> <bean id="alertMailMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from"> <value>yanl_07@163.com</value> </property> <property name="to"> <value>905281577@qq.com,905281577@qq.com</value> </property> <property name="subject" value="Alert - Exception occurred. Please investigate" /> </bean> <bean id="controllerTimer" class="com.huawei.timer.TestController"></bean> <task:scheduled-tasks> <task:scheduled ref="controllerTimer" method="test" cron="*/5 * * * * ?" /> </task:scheduled-tasks>
</beans> express