<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
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
">
<!-- 加载资源文件 -->
<context:property-placeholder location="classpath:/db.properties" />
<!-- 开启扫描 -->
<context:component-scan base-package="com.igeek.crm" />
<!-- 配置DataSource -->
<!-- 使用德鲁伊连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="url" value="${jdbc.url}" />
<property name="driverClassName" value="${jdbc.driverClass}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="${jdbc.maxActive}" />
</bean>
<!-- 整合mybatis,配置一个sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 配置mybatis的核心配置文件 -->
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
<!-- 注入datasource -->
<property name="dataSource" ref="dataSource" />
</bean>
<!-- Mapper代理的方式开发方式二,扫描包方式配置代理 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 配置Mapper接口 -->
<property name="basePackage" value="com.igeek.crm.mapper" />
</bean>
<!-- 通过import引入事务 <import resource="classpath:/applicationContext-tran.xml"/> -->
</beans>
mybatis与Spring整合配置文件
最新推荐文章于 2024-07-25 09:07:25 发布