SpringBoot+Mybatis-Plus 实现踩坑解决(Mapper注入失败)

解决:

1 springBoot 与 mybatis-plus版本是否对应,未校验(据网友说mybatis-plus版本高了有问题);

    这里springboot 2.0.3 mybatis-plus 2.2.0

2 mapper.xml文件中的namespace是否和包名对应,(代码生成后,可能觉得不合适修改了);

3 启动类推荐使用下面注解@MapperScan

@MapperScan("com.aaaa.mapper")
public class Application {

或在Mapper接口上使用@Mapper

4 配置文件:

  本人是在这里的原因:

   mybatis-plus:
     mapper-locations: classpath:com/aaaa/mapper/xml/*Mapper.xml
     type-aliases-package: com.aaaa.model

之前标红部分写成了config-location;

 希望对大家有所帮助!

你可能感兴趣的:(SpringBoot+Mybatis-Plus 实现踩坑解决(Mapper注入失败))