问答详情
源自:3-6 dao层开发

这个问题一直没解决,有没有人帮忙看下

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/imooc/demo/config/dao/SessionFactoryConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: The setting mapUnderScoreToCamelCass is not known.  Make sure you spelled it correctly (case sensitive).



提问者:宝慕林7166548 2020-04-11 09:25

个回答

  • seacat2018
    2020-04-13 08:12:16

    错误提示:mapUnderScoreToCamelCass不能识别,可能的原因是Mybatis的SpringBoot的支持版本不一致,建议少使用XML配置文件。因为SpringBoot2.2以上直接在properties中进行Mybatis的配置了,如下所示:

    <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>2.1.2</version>
            </dependency>

    在 application.properties 配置文件中, 增加
    SpringBoot 和 MyBatis 整合的相关配置:
    #加载 MyBatis 配置文件
    mybatis.mapper-locations=classpath:mapper/*.xml
    mybatis.type-aliases-package=org.edsia.entity //实体类的包路径

    #MySQL数据源配置
    spring.datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
    spring.datasource.username=root
    spring.datasource.password=admin
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver