IllegalStateException: Property 'configuration' and 'configLocation' can not specified with together

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 # 配置冲突了
posted @ 2020-12-05 12:42  小鸣Cycling  阅读(1082)  评论(0编辑  收藏  举报