Spring boot 注入失败

spring boot注入失败的场景主要有java

Application类位置异常

  1. 待注入的类位于Application类所在包的外层;
  2. @ComponentScan扫描的位置没有包括待注入的bean的包

方法做用域问题

该问题咱们在Controller层出现过, 具体代码以下spring

@RestController
@RequestMapping("/mis")
public class XXXrMisController {

    @Autowired
    private MonitorMisService monitorMisService;

    @GetMapping("/Info")
    private CommonResponse<LiveUrlInfoRes> liveUrlInfo() {
        CommonResponse<LiveUrlInfoRes> commonResponse = CommonResponse.success();
        return commonResponse.setResult(monitorMisService.Info(sn, channel));
    }
}

问题出如今liveURLInfo方法的做用域,使用private方法,相应的对MonitorMisService 的依赖就不能注入,改成public就能够了。具体缘由待查app

相关文章
相关标签/搜索