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