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:p="http://www.springframework.org/schema/p"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xmlns:context="http://www.springframework.org/schema/context"
8 xsi:schemaLocation="
9 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
10 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
11 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
12
13 <!-- Properties文件读取配置,base的properties -->
14 <context:property-placeholder location="classpath:jdbc.properties"/>
15
16 <!-- JNDI获取数据源(使用dbcp连接池) -->
17 <bean >
18 <property name="driverClassName" value="${driverClassName}"/>
19 <property name="url" value="${url}"/>
20 <property name="username" value="${uname}"/>
21 <property name="password" value="${password}"/>
22 <property name="initialSize" value="${initialSize}"/>
23 <property name="maxActive" value="${maxActive}"/>
24 <property name="maxIdle" value="${maxIdle}"/>
25 <property name="minIdle" value="${minIdle}"/>
26 <property name="maxWait" value="${maxWait}"/>
27 <property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}"/>
28 <property name="removeAbandoned" value="${removeAbandoned}"/>
29 <!-- sql 心跳 -->
30 <property name= "testWhileIdle" value="true"/>
31 <property name= "testOnBorrow" value="false"/>
32 <property name= "testOnReturn" value="false"/>
33 <property name= "validationQuery" value="select 1"/>
34 <property name= "timeBetweenEvictionRunsMillis" value="60000"/>
35 <property name= "numTestsPerEvictionRun" value="${maxActive}"/>
36 </bean>
37
38 <!--redis 配置 开始-->
39 <bean >
40 <property name="maxActive" value="90" />
41 <property name="maxIdle" value="5" />
42 <property name="maxWait" value="1000" />
43 <property name="testOnBorrow" value="true" />
44 </bean>
45 <bean >
46 <constructor-arg ref="jedisPoolConfig"/>
47 <constructor-arg value="10.0.0.194"/>
48 <constructor-arg value="6379"/>
49 </bean>
50 <bean >
51 <property name="jedisPool" ref="jedisPool"/>
52 </bean>
53 <!-- redis 配置结束 -->
54
55 <!-- mybatis-spring 配置 结束 -->
56
57
58 <!-- enable autowire 启用spring mvc 注解-->
59 <context:annotation-config />
60 <!-- enable transaction demarcation with annotations -->
61 <tx:annotation-driven />
62
63 <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
64 <bean >
65 <property name="dataSource" ref="dataSource" />
66 </bean>
67 <!-- define the SqlSessionFactory, notice that configLocation is not needed when you use MapperFactoryBean -->
68 <bean >
69 <property name="dataSource" ref="dataSource" />
70 <property name="configLocation" value="classpath:mybatis-config.xml" />
71 </bean>
72
73 <!-- AOP 事务处理 开始 -->
74 <aop:aspectj-autoproxy />
75 <aop:config proxy-target-class="true">
76 <aop:pointcut expression="execution(* *org.slsale.service..*(..))" />
77 <aop:advisor pointcut-ref="transService" advice-ref="txAdvice" />
78 </aop:config>
79 <tx:advice >
80 <tx:attributes>
81 <tx:method name="hl*" propagation="REQUIRED" rollback-for="Exception" />
82 </tx:attributes>
83 </tx:advice>
84 <!-- AOP 事务处理 结束 -->
85
86 <!-- scan for mappers and let them be autowired -->
87 <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
88 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
89 <property name="basePackage" value="org.slsale.dao" />
90 </bean>
91 </beans>
![]()
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE configuration
3 PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
4 "http://mybatis.org/dtd/mybatis-3-config.dtd">
5 <configuration>
6 <settings>
7 <!-- changes from the defaults -->
8 <setting name="lazyLoadingEnabled" value="false" />
9 </settings>
10 <typeAliases>
11 <!--这里给实体类取别名,方便在mapper配置文件中使用-->
12 <!-- add by bdqn_hl 2014-2-21 start -->
13 <typeAlias alias="user" type="org.slsale.pojo.User"/>
14 <typeAlias alias="function" type="org.slsale.pojo.Function"/>
15 <typeAlias alias="authority" type="org.slsale.pojo.Authority"/>
16 <typeAlias alias="dataDictionary" type="org.slsale.pojo.DataDictionary"/>
17 <typeAlias alias="role" type="org.slsale.pojo.Role"/>
18 <typeAlias alias="affiche" type="org.slsale.pojo.Affiche"/>
19 <typeAlias alias="goodsInfo" type="org.slsale.pojo.GoodsInfo"/>
20 <typeAlias alias="information" type="org.slsale.pojo.Information"/>
21 <typeAlias alias="goodsPack" type="org.slsale.pojo.GoodsPack"/>
22 <typeAlias alias="goodsPackAffiliated" type="org.slsale.pojo.GoodsPackAffiliated"/>
23 <typeAlias alias="uploadTemp" type="org.slsale.pojo.UploadTemp"/>
24 <typeAlias alias="leaveMessage" type="org.slsale.pojo.LeaveMessage"/>
25 <typeAlias alias="reply" type="org.slsale.pojo.Reply"/>
26 <!-- add by bdqn_hl 2014-2-21 end -->
27
28 <!-- add by bdqn_shy 2014-4-9 start -->
29 <typeAlias alias="userAccountLog" type="org.slsale.pojo.UserAccountLog"/>
30 <!-- add by bdqn_shy 2014-4-9 end -->
31 </typeAliases>
32 </configuration>
mybatis-config.xml