required a single bean, but 2 were found报错,使用mybatis-generator-maven-plugin生成mapper的问题

报错信息

2020-02-22 20:01:11.124 ERROR 6108 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field mapper in com.leo.xingqiyi.service.BaseService required a single bean, but 2 were found:
	- baseMapper: defined in file [D:\Projects\xingqiyi\target\classes\com\leo\xingqiyi\mapper\BaseMapper.class]
	- usersMapper: defined in file [D:\Projects\xingqiyi\target\classes\com\leo\xingqiyi\mapper\UsersMapper.class]


Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed


Process finished with exit code 1

解决方法

需要指定

如果你是用一个base来interface或者abstract class来实现的话

//UsersMapper.java
public interface UsersMapper extends BaseMapper<Users,UsersExample> {}

你可能感兴趣的:(required a single bean, but 2 were found报错,使用mybatis-generator-maven-plugin生成mapper的问题)