Mybatis导入原生配置文件

Spring-Mybatis中导入Mybatis原生配置文件

sqlSessionFactory Bean中设置设置configLocation属性

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

mybatis.xml中添加配置

<?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>  

   <settings>  

     <setting name="mapUnderscoreToCamelCase" value="true"/>  

   </settings>  

</configuration> 

Mybatisproperties文件的引入

使用properties标签,如下,resource是类路径,url是网络路径或磁盘路径资源

<configuration>

<properties resource=”dbconfig.properties” ></properties>

。。。。

原文地址:https://www.cnblogs.com/chenkeyu/p/7842736.html