applicationContext.xml配置

applicationContext.xml配置信息

 

 1  1 <?xml version="1.0" encoding="UTF-8"?>
 2  2 <beans xmlns="http://www.springframework.org/schema/beans"
 3  3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4  4     xmlns:p="http://www.springframework.org/schema/p"
 5  5     xmlns:tx="http://www.springframework.org/schema/tx"
 6  6     xmlns:context="http://www.springframework.org/schema/context"
 7  7     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 8  8         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 9  9         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
10 10 
11 11     <!-- 配置扫描包 -->
12 12     <context:component-scan base-package="com.neuedu.ssm">
13 13         <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
14 14         <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
15 15     </context:component-scan>
16 16     
17 17     <!-- 加载外部文件 -->
18 18     <context:property-placeholder location="classpath:jdbc.properties"/>
19 19     
20 20     <!-- 配置数据库连接池 c3p0-->                     <!-- ComboPooledDataSource存储数据源接口池 -->
21 21     <bean id="comboPooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
22 22         <property name="user" value="${jdbc.user}"></property>
23 23         <property name="password" value="${jdbc.password}"></property>
24 24         <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
25 25         <property name="driverClass" value="${jdbc.driverClass}"></property>
26 26     </bean>
27 27     
28 28     
29 29     <!-- 配置事务管理器 -->
30 30     <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
31 31         <constructor-arg name="dataSource" ref="comboPooledDataSource"/>
32 32     </bean>
33 33     
34 34     <!-- 开启基于注解的事务 -->
35 35     <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>
36 36     
37 37     
38 38     <!-- 配置 SqlSessionFactory -->
39 39     <bean class="org.mybatis.spring.SqlSessionFactoryBean">
40 40         <property name="dataSource" ref="comboPooledDataSource"></property>
41 41         <!-- 配置 mybatis 配置文件的位置和名称 -->
42 42         <property name="configLocation" value="classpath:mybatis-config.xml"></property>
43 43     </bean>
44 44     
45 45     <!-- 配置mapper接口扫描包 -->
46 46     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
47 47         <property name="basePackage" value="com.neuedu.ssm.mapper"></property>
48 48     </bean>
49 49     
50 50 </beans>

 

posted on 2017-12-26 11:06  ALWAYS☆REMIND  阅读(121)  评论(0编辑  收藏  举报

导航