spring整合mybatis的配置文件

来源:互联网 发布:质量好的挎包淘宝店 编辑:程序博客网 时间:2024/05/22 02:24

备忘

<?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:tx="http://www.springframework.org/schema/tx"    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd">    <!--加载配置文件 -->    <context:property-placeholder location="classpath:db.properties" />    <!-- 数据源 -->    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">        <property name="user" value="${jdbc.username}" />        <property name="password" value="${jdbc.password}" />        <property name="jdbcUrl" value="${jdbc.url}" />        <property name="driverClass" value="${jdbc.driverClassName}" />    </bean>    <!--sqlSessionFactory -->    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">        <property name="dataSource" ref="dataSource" />        <!--省略sqlmapconfig.xml-->        <!--<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml"></property>-->                <property name="mapperLocations" value="classpath*:com/zhmhxy/taotao/dao/*.xml"/>                <!--另一种写法-->                <!--<property name="mapperLocations" >-->            <!--<list>-->                <!--<value>classpath*:com/zhmhxy/taotao/dao/*.xml</value>-->            <!--</list>-->        <!--</property>--><property name="plugins"><!--参考:http://blog.csdn.net/estelle_belle/article/details/46356575-->            <array>                <bean class="com.github.pagehelper.PageHelper">                <!--分页工具,在sql语句发送前根据mysql方言拼接limit-->                    <property name="properties" >                        <value>dialect=mysql</value>                    </property>                </bean>            </array>        </property>    </bean>    <!-- 管理mapper接口 -->    <!-- <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">         <property name="mapperInterface" value="com.zhmhxy.taotao.dao.UserMapper"></property>         <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> </bean> -->    <!-- 使用mapper扫描管理所有的代理mapper -->    <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">        <property name="basePackage" value="com.zhmhxy.taotao.dao"></property>    </bean></beans>
原创粉丝点击