35 lines
1.8 KiB
XML
35 lines
1.8 KiB
XML
<?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:context="http://www.springframework.org/schema/context"
|
|
xmlns:aop="http://www.springframework.org/schema/aop"
|
|
xmlns:tx="http://www.springframework.org/schema/tx"
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
http://www.springframework.org/schema/context
|
|
http://www.springframework.org/schema/context/spring-context.xsd
|
|
http://www.springframework.org/schema/aop
|
|
http://www.springframework.org/schema/aop/spring-aop.xsd
|
|
http://www.springframework.org/schema/tx
|
|
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
|
<!-- 1、引入外部 properties 文件 -->
|
|
<context:property-placeholder location="classpath:jdbc.properties" />
|
|
<!-- 2、注册数据源 -->
|
|
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
|
|
<property name="driverClass" value="${jdbc.driverClass}" />
|
|
<property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
|
|
<property name="user" value="${jdbc.user}" />
|
|
<property name="password" value="${jdbc.password}" />
|
|
</bean>
|
|
<!--3、配置Session工厂对象-->
|
|
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
<property name="dataSource" ref="dataSource"></property>
|
|
</bean>
|
|
<!--4、配置扫描的包-->
|
|
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
<property name="basePackage" value="ah.com.dao"></property>
|
|
</bean>
|
|
<!--5、扫描对应的类 IOC创建对象 -->
|
|
<!--扫描注解的类-->
|
|
<context:component-scan base-package="ah.com.service.impl"></context:component-scan>
|
|
</beans> |