SpringBoot使用@Autowired注入报错 Could not autowire

现象:

@Autowired
private UserService userService ;

SpringBoot 启动报错:

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

Description:

Field userService in com.guodx.controller.UserController required a bean of type 'com.guodx.service.UserService' that could not be found.

Action:

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

Process finished with exit code 0

可能出现原因:

  1. Service实现类 没有添加 @Service 注解
    在 UserServiceImpl类 添加 @Service注解,问题解决 ~
  2. Dao实现类 没有添加 @Mapper 注解
发布了7 篇原创文章 · 获赞 0 · 访问量 123

猜你喜欢

转载自blog.csdn.net/weixin_42862834/article/details/105580654
今日推荐