When springboot starts, a bean of type ‘XXX’ not be
Deion:Field mapper in , required a bean of type ‘’ that could not be :Consider defining a bean of type ‘’ in your configuration.
SpringBoot failed to start, telling me that the bean configuration failed;
Solution 1
Add @Mapper annotation,
@Mapper public interface UserDao(){ int insert(UserDomain record); List<UserDomain> selectUsers(); }
Restart, start normally.
Pay special attention:
After adding the @Mapper annotation, this interface will generate the corresponding implementation class at compile time.
It should be noted that methods with the same name cannot be defined in this interface because the same id will be generated.
In other words, this interface does not support overloading.
Note: If you use the @Mapper annotation, each dao needs to add trouble.
Solution 2
Using @MapperScan:
@SpringBootApplication @MapperScan("") public class GctimeApplication { public static void main(String[] args) { (, args); } }
Solution 2: Use @MapperScan to solve this problem well.
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.