且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

配置系列:ssm中applicationContext-mybatis.xml的简单配置

更新时间:2021-06-29 21:56:58



<?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:p="http://www.springframework.org/schema/p"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

        

        <!-- 定义Mybatis的SqlSessionFactory -->

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<!-- 定义数据源 -->

<property name="dataSource" ref="dataSource" />

<!-- 指定calsspath下mybatis全局配置文件 -->

<property name="configLocation" value="classpath:mybatis/mybatis-config.xml"></property>

<!-- 扫描mappers目录以及子目录下的所有xml文件 -->

<!--    <property name="mapperLocations" value="classpath:mybatis/mappers/**/*.xml" /> -->

  

   <!-- 别名扫描包 -->

   <property name="typeAliasesPackage" value="com.simple.sso.pojo"/>

</bean>

        

     <!-- 定义Mapper接口扫描器:让其自动生成接口的代理实现类 -->

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

     <property name="basePackage" value="com.simple.sso.mapper" />

</bean>

</beans>

        



本文转自 兴趣e族 51CTO博客,原文链接:http://blog.51cto.com/simplelife/1695782