最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

SpringBoot Consider defining a bean of type `xxx` in your configuration 错误情况解决(Spring、feign等)

运维笔记admin4浏览0评论

Spring

1、已经使用@Service注解定义了UserService的实现类,但是Spring没有扫描到。

解决方法:

(1)将当前模块的Dao类、Service类、Entity类、Controller类放在和XxxApplication启动类同一目录下或者子目录下。

(2)在xxxApplication启动类加上 @ComponentScan(“com”) 注解。

2、UserService启动装配时变量名默认为实现类的名字userServiceImpl,实现类是UserServiceImpl类,而我们使用@Autowired注解时变量名为userService。

解决办法:

将实现类的@Service改为@Service(“userService”)。

OpenFeign

1、使用了OpenFeign来调用其他微服务的接口,但是OpenFeign相关的jar包没有完成导入。

2、使用OpenFeign来调用其他微服务的接口时,XxxApplication启动类未加@EnableFeignClinets注解。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论