spring 配置

<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"

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>

转载于:https://my.oschina.net/u/946001/blog/408320

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值