Description:

Field districtService in com.ymzh.controller.admin.MovieHandler required a bean of type 'com.ymzh.service.DistrictService' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.ymzh.service.DistrictService' in your configuration.

 

这是我这两天第二次遇到这个问题了,今天特别来做下记录。

看到一篇博客感觉写的很好,在这里贴一下。

关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案:https://blog.csdn/a532672728/article/details/77702772/

 

那么我这次犯错的原因,竟然是:把implements Service  写成了 implements Dao的接口。

 

出现这个问题,一般先去检查以下几个点吧。

1、Service接口是否被实现了(我只是手误了5555),

2、实现类是否加了Service注解,或者Component注解。

3、controller中是否加了@Autowired注解。

这些都没有问题的话,那再去看看那篇博客吧,也许否能够有所帮助。

 

更多推荐

踩坑记录:关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your