NoBug. 2022-07-05 19:26 采纳率: 50%
浏览 163
已结题

service层有接口类和实现类,在controller层注入接口类就报错找不到依赖,而注入实现类就不报错

问题遇到的现象和发生背景

springboot注入失败

问题相关代码,请勿粘贴截图

@Autowired
private ToBrailleImpl toBrailleImpl;
service层有接口类和实现类,在controller层注入接口类就报错找不到依赖,而注入实现类就不报错

运行结果及报错内容

@Autowired
private ToBrailleMsgInterface toBraille;
报错:
Description:

Field toBraille in tobraille1.controller.ToBraille required a bean of type 'tobraille1.service.serviceInterface.ToBrailleMsgInterface' 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 'tobraille1.service.serviceInterface.ToBrailleMsgInterface' in your configuration.

  • 写回答

2条回答 默认 最新

  • Climbing-pit 2022-07-06 08:48
    关注

    看下service实现类有没有service注解

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 7月14日
  • 已采纳回答 7月6日
  • 创建了问题 7月5日