idea2021.1 Action:Consider defining a bean named ‘Forecast1‘ in your configuration.

编程知识 更新时间:2023-05-02 05:24:40
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-07-15 19:27:05.477 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

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

Description:

A component required a bean named 'Forecast' that could not be found.


Action:

Consider defining a bean named 'Forecast' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:55032', transport: 'socket'

背景

好久没有写东西了,最近在做项目中使用的是idea2021.1最新版本,多模块项目开发,启动java应用的时候,出现依赖注入失败的情况

操作

 仔细检查了包路径扫描情况

@SpringBootApplication(scanBasePackages = {"com.milla.study"})

 也检查了被注入类的注解情况

package com.milla.study.service.impl;
@Slf4j
@Service("Forecast")
@ConditionalOnProperty(prefix = "spring.config", name = "enableAlgorithm", havingValue = "true")
public class ForecastServiceImpl implements AlgorithmHandlerService<SymptomParamDTO, PrognosticForecastResponseDTO> {
//伪代码
}

 也检查了引用位置代码

 @Resource(name = "Forecast")
    private AlgorithmHandlerService handlerService;

查了很多资料网上都说是扫描包,注解等问题,

但是经过测试发现,这个时候的同路径只有该类注入失败,而且,idea自带的点击跳转功能是好的,能跳转过去;

这个时候我考虑是不是缓存的问题,重启了idea,但是并不起作用,

这时,我复制了一个能注入的类改个名字,发现是能注入的,此时把该问题定位为类名的问题,果不其然,把名字改成ForecastServiceImpl 又注入失败,

至此,大致解决了这个问题,捣蛋鬼居然是类文件的名字,idea2021.1.3最新版应该存在一些bug没有修复

总结:没有完美的工具,有可能在编程过程中,有这样那样的问题,但未必是自己写错了 

更多推荐

idea2021.1 Action:Consider defining a bean named ‘Forecast1‘ in your configurati

本文发布于:2023-04-26 05:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/a0839034fdd5d2589a9441128ddd2d72.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:defining   Action   bean   configuration   named

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104378文章数
  • 26212阅读数
  • 0评论数