標籤:配置 spring mybatis
<?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>
配置系列:ssm中applicationContext-mybatis.xml的簡單配置