Consider defining a bean of type 'com.service.UserService' in your configuration solution

Project scenario:

Used by SpringBoot+MybatisPlus.


Problem Description

Could not autowire. No beans of ‘UserMapper’ type found.


Cause Analysis:

not scanned

Because this is the code for SpringBoot to integrate Mybatis, the @Mapper annotation is used in the Mapper interface class.

But it would be troublesome to add @Mapper annotation to each Mapper interface class, so the @MapperScan annotation is used to scan Mapper interface classes in batches.


solution:

Add the @MapperScan("com.xxx.xxx.mapper") annotation to the xxxApplication startup class.

For example: Create a new object, store the read data in it, and then replace it.

Guess you like

Origin blog.csdn.net/aaxzsuj/article/details/129328922