原因:配置重复导致冲突
举例:
application.yml
mybatis:
mapper-locations: classpath:mapper/*Mapper.xml
type-aliases-package: com.mmdz.entity
# sql 打印
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
config-location: classpath:mybatis/mybatis-config.xml
在springboot的application.yml不能同时使用以下两个配置,换句话说,两者配置方式只能取其一.
解决:
application.yml
mybatis: mapper-locations: classpath:mapper/*Mapper.xml type-aliases-package: com.mmdz.entity config-location: classpath:mybatis/mybatis-config.xml
mybatis-config.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="cacheEnabled" value="false" /><!-- 暂时禁用缓存 --> <setting name="logImpl" value="STDOUT_LOGGING"/><!-- 打印sql--> </settings> <plugins> <plugin interceptor="com.mmdz.common.interceptor.PaginationInterceptor"></plugin> </plugins> </configuration>