码迷,mamicode.com
首页 > 编程语言 > 详细

spring文件的配置 方便以后查看

时间:2014-05-12 07:45:56      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   ext   

bubuko.com,布布扣
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4        xmlns:aop="http://www.springframework.org/schema/aop"
 5        xmlns:tx="http://www.springframework.org/schema/tx"
 6        xmlns:context="http://www.springframework.org/schema/context"
 7        xsi:schemaLocation="http://www.springframework.org/schema/beans
 8                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
 9                            http://www.springframework.org/schema/aop 
10                            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
11                            http://www.springframework.org/schema/context 
12                            http://www.springframework.org/schema/context/spring-context-2.5.xsd
13                            http://www.springframework.org/schema/tx 
14                            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
15        <!-- 主键扫描 -->
16     <context:component-scan base-package="kite.dao.impl,kite.service.impl,kite.struts2.action"></context:component-scan>
17         
18         <!-- 
19             分散配置    
20          -->
21      <context:property-placeholder location="classpath:jdbc.properties" />
22       <!--
23                数据源 c3p0
24       
25        -->                     
26      <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
27          <property name="jdbcUrl" value="${jdbc.url}"></property>
28          <property name="user" value="${jdbc.username}"></property>
29          <property name="password" value="${jdbc.password}"></property>
30          <property name="driverClass" value="${jdbc.driverClass}"></property>
31          
32          <property name="maxPoolSize" value="${c3p0.pool.size.maxsize}"></property>
33          <property name="minPoolSize" value="${c3p0.pool.size.minsize}"></property>
34          <property name="initialPoolSize" value="${c3p0.pool.size.init}"></property>
35          <property name="acquireIncrement" value="${c3p0.pool.size.increment}"></property>
36      </bean>
37      
38      <!-- 
39          本地会话工厂bean,spring整合hibernate的核心入口
40       -->
41      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
42          <!-- 注入数据源 -->
43          <property name="dataSource" ref="dataSource"></property>
44          <!-- 指定hibernate配置文件的位置 -->
45          <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
46          <!-- 指定映射文件的位置 -->
47          <property name="mappingDirectoryLocations">
48              <list>
49                  <value>classpath:kite/domain</value>
50              </list>
51          </property>
52      </bean>    
53      <!-- 事务管理器,在service层面上实现事务管理,而且达到平台无关性 -->
54         <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
55             <property name="sessionFactory" ref="sessionFactory" />
56         </bean>
57         
58         <!-- 配置事务通知 -->
59         <tx:advice id="txAdvice" transaction-manager="txManager">
60             <tx:attributes>
61                 <tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT" />
62                 <tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT" />
63                 <tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT" />
64                 <tx:method name="batch*" propagation="REQUIRED" isolation="DEFAULT" />
65                 <tx:method name="new*" propagation="REQUIRED" isolation="DEFAULT" />
66                 
67                 <tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
68                 <tx:method name="load*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
69                 <tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
70                 
71                 <tx:method name="*" propagation="REQUIRED" isolation="DEFAULT" />
72             </tx:attributes>
73         </tx:advice>
74         
75         <!-- aop事务配置 -->
76         <aop:config>
77             <aop:advisor advice-ref="txAdvice" pointcut="execution(* *..*Service.*(..))"/>
78         </aop:config>
79   </beans>                         
bubuko.com,布布扣

 

spring文件的配置 方便以后查看,布布扣,bubuko.com

spring文件的配置 方便以后查看

标签:style   blog   class   code   java   ext   

原文地址:http://www.cnblogs.com/kite/p/3720872.html

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