IllegalStateException: Property 'configuration' and 'configLocation' can not specified with together
阿新 • • 發佈:2020-12-05
SpringBoot + Mybatis 配置遇到的錯誤
錯誤日誌
Caused by: java.lang.IllegalStateException: Property 'configuration' and 'configLocation' can not specified with together at org.springframework.util.Assert.state(Assert.java:76) ~[spring-core-5.3.1.jar:5.3.1] at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:488) ~[mybatis-spring-2.0.6.jar:2.0.6] at org.mybatis.spring.SqlSessionFactoryBean.getObject(SqlSessionFactoryBean.java:633) ~[mybatis-spring-2.0.6.jar:2.0.6]
原因
- 配置重複導致衝突
已經
/** * MyBatis 自定義配置 * * @author xiaoming * @date 2020-11-29 15:59 */ @org.springframework.context.annotation.Configuration public class MybatisConfig { @Bean public ConfigurationCustomizer configurationCustomizer() { return new ConfigurationCustomizer() { @Override public void customize(Configuration configuration) { // 開啟駝峰命名, 如: department_name -- 對映 ---> departmentName configuration.setMapUnderscoreToCamelCase(true); } }; } }
# myBatis 配置
mybatis:
configuration:
# 駝峰命名
map-underscore-to-camel-case: true # 配置衝突了