1.依赖关系
我按照官网首页所说导入了下面的依赖,结果无法注入mapper
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.1</version>
</dependency>
解决:再导入springboot相关的mybatis-plus依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
2.mapper注入的测试路径问题
最开始的测试路径我是直接写在了test目录下面,结果导致springboot无法找到测试类
Unable to find a @SpringBootConfiguration,
you need to use @ContextConfiguration or @SpringBootTest(classes=...)
with your test
之后加上了classes之后不报此错误,此处classes为springboot的主启动类
@SpringBootTest(classes = SpringbootMybatisplusApplication.class)