spring-mybatis-context.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: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-4.0.xsd">

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>${spring.datasource.driver-class-name}</value>
        </property>
        <property name="url">
            <value>${spring.datasource.url}</value>
        </property>
        <property name="username">
            <value>${spring.datasource.username}</value>
        </property>
        <property name="password">
            <value>${spring.datasource.password}</value>
        </property>
    </bean>


    <bean id="sqlSessionFactory"
        class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="typeAliasesPackage"
            value="com.mybatis.mydemo.model" />
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations"
            value="com.mybatis.mydemo.mapper.**.xml"></property>
        <property name="plugins">
            <array>
                <bean
                    class="com.base.mybatis.PagingInterceptor"></bean>
            </array>
        </property>
    </bean>

    <bean id="sqlSession"
        class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0">
            <ref bean="sqlSessionFactory" />
        </constructor-arg>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.mybatis.mydemo.mapper"></property>
        <property name="sqlSessionFactoryBeanName"
            value="sqlSessionFactory" />
    </bean>

    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" />
</beans>  
 

发布了44 篇原创文章 · 获赞 27 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/m0_38031406/article/details/93746940
今日推荐