Springboot默认配置扫描不到Controller、Mapper包等问题

Spring Boot整合MyBatis扫不到mapper包问题解决

在Springboot整合mybaties的过程中,楼主出现了扫码不到mapper包的问题,错误原因如下:

错误原因:

Description:

Parameter 0 of constructor in edu.seig.mybatiesspringboot.controller.ProblemController required a bean of type 'edu.seig.mybatiesspringboot.mapper.ProblemMapper' that could not be found.


Action:

Consider defining a bean of type 'edu.seig.mybatiesspringboot.mapper.ProblemMapper' in your configuration.

楼主的项目结构如下:

可以看出启动类的放置位置并无问题,因此默认配置应该能扫到,但是依旧出现错误。

最后找到错误原因是依赖版本过低的问题。

原先楼主的依赖:

 <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.0</version>
        </dependency>

升级成:

  <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>3.0.3</version>
        </dependency>

之后运行,成功解决。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值