Field userService in com.demo.web.Controller.HomeController required a single bean, but 2 were found:
- userServiceImpl: defined in file [C:UsersxxxxDesktop
maven-projectsweb-app argetclassescomdemowebControllerUserServiceImpl.class]
- IUserService: defined in file [C:UsersxxxxDesktop
maven-projectsweb-app argetclassescomdemowebControllerIUserService.class]
一、指定bean名字为 userServiceImpl
@Autowired
private IUserService userServiceImpl;
二、在@Service里指定服务名字
@Service("userService")
public class UserServiceImpl implements IUserService {
@Autowired
private IUserService userService;