永州建设公司网站,青岛建设银行银行招聘网站,网站建设规划书ppt,wordpress网站amp项目采用的是 mybatis#xff0c; 后续引入了 mybatisPlus#xff0c;用 mybatisX 创建的四个类一直报错#xff0c;提示找不到符号#xff0c;意识到 mybatis 和 mybatisPlus 的兼容性问题#xff0c;通过修改配置 两者的配置如下
#配置mybatis配置
mybatis:type-aliase…项目采用的是 mybatis 后续引入了 mybatisPlus用 mybatisX 创建的四个类一直报错提示找不到符号意识到 mybatis 和 mybatisPlus 的兼容性问题通过修改配置 两者的配置如下
#配置mybatis配置
mybatis:type-aliases-package: top.year21.computerstore.entitymapper-locations: classpath:mybatis/mapper/*.xmlconfiguration:#开启在mybatis处理过程中打印出对应的sql语句功能log-impl: org.apache.ibatis.logging.stdout.StdOutImpl#开启数据库字段自动转换为驼峰命名map-underscore-to-camel-case: true# 配置 mybatisPlus 配置
mybatis-plus:type-aliases-package: top.year21.computerstore.plusEntitymapper-locations: classpath:mapper/*.xml
启动时又报错如下 查到可能是 MyBatis 和 MyBatisPlus 版本兼容性问题
原配置 其中 3.5.9 的版本可能还需要新增依赖 所以我将 mybatisPlus 的依赖版本降为了 3.5.3 成功启动项目。
调用接口方法时报错 查到是 xml 文件识别的问题在网上查了很久但是一直不能解决注意到 在执行到 IUserServiceImpl 中的第 91行时 会调用到 mapper 提供的方法根据错误递归栈发现后续直接走的 mybatisplus没有走 mybatis而我的 mybatisPlus 配置的 classpath 和 type-aliases-package 并没有包含UserMapper 对应的 xml 文件 后续通过修改 mybatisplus 的配置并将 plusEntity 中的 TProductCategory 和 mapper 中的 TProductCategoryMapper 分别移动到 entity 和 mybatis/mapper 中解决了问题。
#配置mybatis配置
#mybatis:
# type-aliases-package: top.year21.computerstore.entity
# mapper-locations: classpath:mybatis/mapper/*Mapper.xml
# configuration:
# #开启在mybatis处理过程中打印出对应的sql语句功能
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# #开启数据库字段自动转换为驼峰命名
# map-underscore-to-camel-case: true# 配置 mybatisPlus 配置
mybatis-plus:type-aliases-package: top.year21.computerstore.entitymapper-locations: classpath:mybatis/mapper/*Mapper.xml # MyBatis-Plus 的 XML Mapper 路径可选如果使用 XMLconfiguration:map-underscore-to-camel-case: truelog-impl: org.apache.ibatis.logging.stdout.StdOutImpl
总结一下当有 MyBatisPlus 时会优先选用 MyBatisPlus 而不是 MyBatis所以 MyBatisPlus 的配置需要包含所有 xml 和 entiy避免识别不到的错误。实际上当引入 MyBatisPlus MyBatis 的增强之后MyBatis 的依赖也以及被引入了不需要单独引入或配置。