记录自己今天遇到的一个小bug:在做头像上传功能时,出现如下错误,我有一个Properties类是和配置文件所绑定的,@ConfigurationProperties:告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定;

prefix = "":配置文件中下面的所有属性进行一一映射,一般@Component只有这个组件是容器中的组件,才能用容器提供的@ConfigurationProperties功能;

解决方法 1)直接把@Component注解注释掉

疑问:我也不知道为啥会成功,按理来说都没放进容器中,怎么会注入成功的,可能是其他注解有把这个类放入容器的功效,我现在也不知道,我用的注入方式是@Autowired,加上@Component注解以后,就会显示有两个bean,所以我注释掉一个就成功了。哪位大佬知道原理了可以在评论区告我一下,我想知道原因,万分感谢!

2)第二种方法就是将@Autowired注解改为@Resource(name="你的Properties类名称首字母小写即可"),这样虽然有两个bean,但是指定了要导入哪个bean,IOC容器就会给你提供相应的bean。

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans,报错解决相关推荐

  1. Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans,....

    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or us ...

  2. Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or us

    项目原来一直好好地,原来不怎么启动的模块,来了新任务,去启动了一下,发现报错 Consider marking one of the beans as @Primary, updating the c ...

  3. SpringBoot中提示:Consider marking one of the beans as @Primary, updating the consumer to accept multipl

    场景 SpringBoot项目在启动时提示: Consider marking one of the beans as @Primary, updating the consumer to accep ...

  4. 【报错解决】The dependencies of some of the beans in the application context form a cycle:

    一.报错信息 *************************** APPLICATION FAILED TO START ***************************Descriptio ...

  5. mysql报错:Duplicate entry ‘xx‘ for key ‘PRIMARY‘ 解决可行方案。已解决

    mysql报错:Duplicate entry 'xx' for key 'xxux1' 解决可行方案.已解决 web开发多次遇到Duplicate entry 'xx' for key 'PRIMA ...

  6. 【Java报错】多数据源mapper异常more than one `primary` bean found among candidates: [sqlSessionFactory] 问题分析解决

    1. 报错分析 项目使用了多个数据源,但是没有使用持久层框架,后期加入了 mybatis-plus 插件,启动项目时报错,信息如下: 2021-08-19 09:16:20 ERROR [,,,] [ ...

  7. 报错 org.springframework.beans.factory.BeanCreationException

    2019独角兽企业重金招聘Python工程师标准>>> 一.问题背景: spring mvc eclipse启动报错:org.springframework.beans.factor ...

  8. SpringBoot报错:Could not autowire. No beans of ‘DiscussantMapper‘ type found

    SpringBoot报错:Could not autowire. No beans of 'DiscussantMapper' type found 一.资源 @Mapper和@Repository注 ...

  9. [解决方法] spring-data-mongo 配置报错org.springframework.beans.factory.BeanCreationException

    [解决方法] spring-data-mongo 配置报错org.springframework.beans.factory.BeanCreationException 参考文章: (1)[解决方法] ...

最新文章

  1. 相识、相恋、相伴【与51CTO的故事】
  2. Spring 中策略模式的 2 个经典应用,可以用来怼面试官了
  3. 吴恩达深度学习 ——深层神经网络(选择题)
  4. Robot Framework(十四):使用RF进行接口测试(上)
  5. android 距离测量工具,尺子距离测量app
  6. 数据库事务(Transaction)详解
  7. MyBatis中的JdbcType映射介绍
  8. 如何给华硕笔记本在光驱位加装另一块linux系统固态硬盘?
  9. Python 网络爬虫从0到1 (2):网络爬虫的特性、问题与规范
  10. python 实现126邮箱登录
  11. 前端播放视频有声音没有画面
  12. Python爬取微信公众号文章、点赞数
  13. python在线电影网站-四
  14. python 英文语义分析_spinrewriter英文伪原创工具,Python对接API示例
  15. 红米note4x线刷miui9国际版开发版
  16. 动态内存管理——tlsf
  17. vnc viewer 绿色版,6款超好用的vnc viewer 绿色版
  18. Win10 微软输入法(微软拼音) 不显示 选字栏(无法选字) 解决方法
  19. Keil5进行STM32F103C8T6的软件仿真
  20. MBR DBR分区系统详述

热门文章

  1. 一位资深HR的职场感言
  2. 输入法的半角和全角切换
  3. PostgreSQL 修改用户密码
  4. 物流行业的大数据发展与应用
  5. 《基于张量网络的机器学习入门》学习笔记8(Shor算法)
  6. PS基础入门教程-如何制作GIF动画
  7. 图片无损压缩(ubuntu 安装 )
  8. pyecharts 中应用seaborns 调色板
  9. Kali学习 | 漏洞利用:4.4 控制Meterpreter
  10. CT影像文件格式DICOM详解