码迷,mamicode.com
首页 > 编程语言 > 详细

spring 整合 mybatis (不含物理分页)

时间:2016-08-06 08:17:49      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

 

<?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:util="http://www.springframework.org/schema/util" 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/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

    <util:properties id="db" location="classpath:db.properties"></util:properties>
    <context:annotation-config />
    <context:component-scan base-package="cn.zno" />

    <bean id="dataSourceTest" class="org.apache.commons.dbcp2.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="#{db[‘jdbc.driverClassName‘]}" />
        <property name="url" value="#{db[‘jdbc.url‘]}" />
        <property name="username" value="#{db[‘jdbc.username‘]}" />
        <property name="password" value="#{db[‘jdbc.password‘]}" />
        <property name="defaultAutoCommit" value="true" />
    </bean>

    <bean id="txManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSourceTest" />
    </bean>

    <tx:annotation-driven transaction-manager="txManager" />

    <!-- ================= -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSourceTest" />
        <property name="configLocation" value="classpath:mybatis-config.xml" />
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="cn.zno.dao" />
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    </bean>
    
    <bean id="aService" class="cn.zno.service.AService"></bean>
    
</beans>

 

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <mappers>
    <package name="cn.zno.dao"/>
  </mappers>
</configuration>

 

spring 整合 mybatis (不含物理分页)

标签:

原文地址:http://www.cnblogs.com/zno2/p/4785330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!