码迷,mamicode.com
首页 > 移动开发 > 详细

applicationContext.xml

时间:2017-12-05 13:33:03      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:entity   comm   conf   factor   read   tor   eal   drive   close   

<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

<!-- 设置扫描包的注解标签 -->
<context:component-scan base-package="org.sujing"/>

<!-- 数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/dianshang"/>
<property name="username" value="root"/>
<property name="password" value="123"/>
<!-- 连接池启动时的初始值 -->
<property name="initialSize" value="3"/>
<!-- 连接池的最大值 -->
<property name="maxActive" value="800"/>
<!-- 最大空闲值 -->
<property name="maxIdle" value="100"/>
<!-- 最小空闲值 -->
<property name="minIdle" value="3"/>
<!-- 是否启用超时自动移除空闲链接 -->
<property name="removeAbandoned" value="false"/>
<!-- 超时时间 -->
<property name="removeAbandonedTimeout" value="18000"/>
<!-- 超时等待时间 -->
<property name="maxWait" value="10000"></property>
</bean>

<!-- SqlSessionFactory是一个sql会话工厂,在这个工厂里面取得一个session会话丢给客户端使用 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="typeAliasesPackage">
<value>org.sujing.entity</value>
</property>
<property name="mapperLocations">
<value>classpath:org/sujing/mapper/*.xml</value>
</property>
</bean>

<!-- 扫描mybatis操作数据库的接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage">
<value>org.sujing.dao</value>
</property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>

<!-- 事务处理 -->
<aop:config>
<aop:pointcut expression="execution(* org.sujing.service..*.*(..))" id="trPointcut"/>
<aop:advisor advice-ref="trAdvice" pointcut-ref="trPointcut"/>
</aop:config>

<tx:advice id="trAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>

</beans>

applicationContext.xml

标签:entity   comm   conf   factor   read   tor   eal   drive   close   

原文地址:http://www.cnblogs.com/supiaopiao/p/7986103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!