码迷,mamicode.com
首页 > 移动开发 > 详细

Spring+Mybatis的applicationContext.xml配置文件

时间:2017-05-28 19:37:36      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:isp   配置文件   service   schema   pos   ring   name   cto   事务   

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
     
    <bean id="config" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
        <property name="locations">
        <list>
                <value>classpath:database.properties</value>
        </list>
        </property>
    </bean>
    
    <!-- 1. 配置数据源 -->
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>${driver}</value>
        </property>
        <property name="url">
            <value>${url}</value>

        </property>
        <property name="username">
            <value>${user}</value>
        </property>
        <property name="password">
            <value>${password}</value>
        </property>
    </bean>
    
    
    
    <!-- 2. 配置sqlsession -->
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:mybatis-config.xml" />
    </bean>
    
    
    <!-- 3. 配置Dao -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.dao" />
    </bean>
    
    <!-- 4. 配置serccvvice扫描注解 -->
    <context:annotation-config />
    <context:component-scan base-package="com.service" />
    
    
    <!-- 5.配置事务 -->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>

</beans>

 

 

Spring+Mybatis的applicationContext.xml配置文件

标签:isp   配置文件   service   schema   pos   ring   name   cto   事务   

原文地址:http://www.cnblogs.com/EzioSyh/p/6916369.html

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