当前使用版本(必填,否则不予处理)
spring-boot-starter-parent:2.5.1 spring-boot-starter-test:2.5.1 mybatis-plus-boot-starter:3.4.3.1 mybatis-plus-boot-starter-test:3.4.3.1 com.h2database:h2:1.4.200
该问题是如何引起的?(确定最新版也有问题再提!!!)
针对Mappter做单元测试,使用@MybatisPlusTest,无法识别resource目录下的schema.sql和data.sql。
使用配置文件
spring.sql.init.schema-locations=classpath:schema.sql
spring.sql.init.data-locations=classpath:data.sql
无效,没有解析schema.sql和执行data.sql。
使用已经deprecate的配置 spring.datasource.schema=classpath:schema.sql
spring.datasource.data=classpath:data.sql
能正常完成测试。
重现步骤(如果有就写完整)
引入以上各组件版本,编写相关代码,使用@MyBatisPlusTest代替@MybatisTest,application-test.yml填写对应配置文件。 @ActiveProfiles("test")指定加载test配置。
报错信息
如果不写任何配置或者使用spring.sql.init.schema-locations和spring.sql.init.data-locations,无法完成测试,提示脚本中的shema和data table不存在。 改为spring.datasource.schema和spring.datasource.data后解决问题。
建议更新版本,能自动是被resource下的schema.sql和data.sql,这两个文件在@MyBatisTest下是不需要做任何配置就自动加载的。
Comment From: qmdx
建议更新版本 什么意思!
Comment From: wxh20114746
大佬, mybatis-plus-boot-starter-test没有maven包?