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

来源:3-6 dao层开发

宝慕林7166548

2020-04-11 09:25

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).



写回答 关注

1回答

  • 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

SpringBoot+MyBatis搭建迷你小程序

SpringBoot+MyBatis搭建小程序后台

91500 学习 · 621 问题

查看课程

相似问题