默认加载 mybatis-default.xml,可通过 mybatis.configLocation 参数指定 mybatis-config.xml 文件
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.jeesite.common.io;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.lang.ExceptionUtils;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -14,6 +13,7 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 资源供给类
|
||||
@@ -66,7 +66,7 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
|
||||
*/
|
||||
public static String getResourceFileContent(String location){
|
||||
try(InputStream is = ResourceUtils.getResourceFileStream(location)){
|
||||
return IOUtils.toString(is, EncodeUtils.UTF_8);
|
||||
return IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||
}catch (IOException e) {
|
||||
throw ExceptionUtils.unchecked(e);
|
||||
}
|
||||
@@ -78,8 +78,7 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
|
||||
*/
|
||||
public static Resource[] getResources(String locationPattern){
|
||||
try {
|
||||
Resource[] resources = resourceResolver.getResources(locationPattern);
|
||||
return resources;
|
||||
return resourceResolver.getResources(locationPattern);
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.unchecked(e);
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?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="cacheEnabled" value="true"/>
|
||||
|
||||
<!-- 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载。 -->
|
||||
<setting name="lazyLoadingEnabled" value="true"/>
|
||||
|
||||
<!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则,每种属性将会按需要加载。 -->
|
||||
<setting name="aggressiveLazyLoading" value="true"/>
|
||||
|
||||
<!-- 是否允许单条sql 返回多个数据集 (取决于驱动的兼容性) default:true -->
|
||||
<setting name="multipleResultSetsEnabled" value="true"/>
|
||||
|
||||
<!-- 是否可以使用列的别名 (取决于驱动的兼容性) default:true -->
|
||||
<setting name="useColumnLabel" value="true"/>
|
||||
|
||||
<!-- 允许JDBC 生成主键。需要驱动器支持。如果设为了true,这个设置将强制使用被生成的主键,有一些驱动器不兼容不过仍然可以执行。 default:false -->
|
||||
<setting name="useGeneratedKeys" value="false"/>
|
||||
|
||||
<!-- 指定 MyBatis 如何自动映射 数据基表的列 NONE:不映射 PARTIAL:部分 FULL:全部 -->
|
||||
<setting name="autoMappingBehavior" value="PARTIAL"/>
|
||||
|
||||
<!-- 这是默认的执行类型(SIMPLE: 简单;REUSE: 执行器可能重复使用prepared statements语句;BATCH: 执行器可以重复执行语句和批量更新) -->
|
||||
<setting name="defaultExecutorType" value="SIMPLE"/>
|
||||
|
||||
<!-- 使用驼峰命名法转换字段。 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
|
||||
<!-- 设置本地缓存范围 session:就会有数据的共享 statement:语句范围 (这样就不会有数据的共享 ) defalut:session -->
|
||||
<setting name="localCacheScope" value="SESSION"/>
|
||||
|
||||
<!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型 -->
|
||||
<setting name="jdbcTypeForNull" value="NULL"/>
|
||||
|
||||
<!-- 迭代集合的时候如果空值,则忽略而不抛出异常 -->
|
||||
<setting name="nullableOnForEach" value="true"/>
|
||||
|
||||
<!-- 返回值为Map时,当返回空值字段时,仍然需要返回这个Key -->
|
||||
<setting name="callSettersOnNulls" value="true"/>
|
||||
|
||||
</settings>
|
||||
|
||||
<!-- 类型别名 -->
|
||||
<typeAliases>
|
||||
<typeAlias alias="Page" type="com.jeesite.common.entity.Page" /><!--分页 -->
|
||||
</typeAliases>
|
||||
|
||||
<!-- 插件配置 -->
|
||||
<plugins>
|
||||
<plugin interceptor="com.jeesite.common.mybatis.interceptor.DataSourceInterceptor" />
|
||||
<plugin interceptor="com.jeesite.common.mybatis.interceptor.PaginationInterceptor" />
|
||||
</plugins>
|
||||
|
||||
</configuration>
|
||||
@@ -35,7 +35,7 @@ server:
|
||||
schemeHttps: false
|
||||
|
||||
#======================================#
|
||||
#========== Database sttings ==========#
|
||||
#========= Database settings ==========#
|
||||
#======================================#
|
||||
|
||||
# 数据库连接
|
||||
@@ -99,9 +99,6 @@ logging:
|
||||
# MyBatis 相关
|
||||
mybatis:
|
||||
|
||||
# MyBatis 配置文件
|
||||
configLocation: /mybatis/mybatis-default.xml
|
||||
|
||||
# Mapper文件刷新线程
|
||||
mapper:
|
||||
refresh:
|
||||
|
||||
Reference in New Issue
Block a user