一、抛出异常

Parameter 0 of constructor in com.ylz.supervise.childmodule.sys.log.strategy.StrategyContext required a single bean, but 2 were found:- logBpService: defined in file [H:\item\radiate\radiate-supervise\target\classes\com\ylz\supervise\childmodule\sys\log\service\LogBpService.class]- logHsService: defined in file [H:\item\radiate\radiate-supervise\target\classes\com\ylz\supervise\childmodule\sys\log\service\LogHsService.class]Action:Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

二、产生场景

由于业务功能需求需要日志记录操作信息,为此建立了一个日志策略类方便多模块记录。结果当加入了第二个模块时就出现异常。项目无法启动,启动则抛出上述异常。

三、部分代码

  1. 日志策略类

    package com.ylz.supervise.childmodule.sys.log.strategy;import org.springframework.context.annotation.Primary;
    import org.springframework.stereotype.Service;/*** @ClassName: 日志策略* @author: Created by CCJ on 2020/5/7.**/
    @Service
    public interface LogStrategy {/*** 日志保存方法*/void saveLog(Object... args) throws Exception;
    }
    
  2. 实现类

    package com.ylz.supervise.childmodule.sys.log.strategy;import com.ylz.supervise.childmodule.sys.comm.CommService;/*** 策略类*/
    @CommService
    public class StrategyContext {private LogStrategy strategy;public StrategyContext(LogStrategy strategy) {this.strategy = strategy;}public void executeStrategy(Object... args) throws Exception {strategy.saveLog(args);}
    }

四、产生问题原因

产生问题的原因是由于实现类注解@CommService的使用。具体原因暂时还不清楚,暂时解决是直接把注解去掉,不自动注入。因为项目内调用部分目前也是使用new的方式,所以影响不大。不过还是没搞明白具体原因,因为初步使用策略类还未了解多少。待日后学成时再回头看。嘿嘿,Σσ(・Д・;)我我我什么都没做!!!

异常:Parameter 0 of constructor in com.ylz.supervise.childmodule.sys.log.strategy.StrategyContext req记相关推荐

  1. 解决:Parameter 0 of constructor in xxx required a bean of type ‘xxx‘ that could not be found.

    运行报错: Parameter 0 of constructor in com.xxx.Crawler required a bean of type 'java.lang.String' that ...

  2. 代码Service方法都报 Parameter 0 of constructor in com.fan.xx required a single bean, but 2 were found原因分析

    今天遇到一个问题,拉取同事的代码,发现编译不过,报错如下: *************************** APPLICATION FAILED TO START ************** ...

  3. 解决报错Parameter 0 of constructor in XXX required a bean...elasticsearch 继承ElasticsearchConfiguration方法

    SpringBoot中构建带有含参构造函数的Bean,解决报错Parameter 0 of constructor in XXX required a bean ,elasticsearch继承Abs ...

  4. 解决:Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found

    解决:Parameter 0 of constructor in com.mise.smart.entity.HrmNoticeEntity required a bean of type 'java ...

  5. Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found.

    今天在搭建微服务项目的时候遇到了一个问题 项目结构 实际的场景是OperationLogService需要注入OperationLogMapper,也就是最常见的业务层依赖数据层,但是项目启动的时候报 ...

  6. spring异常Unsatisfied dependency expressed through constructor parameter 0

    异常信息: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with nam ...

  7. Parameter 0 of method errorPageCustomizer in ErrorMvcAutoConfiguration 异常解决

    Parameter 0 of method errorPageCustomizer in ErrorMvcAutoConfiguration required a bean of type 'xxx. ...

  8. 一次由Spring构造注入引发的错误Parameter 1 of constructor in org.rongyilian.service.impl.VerificationCodeService

    SrpringBoot服务启动后报错如下: Description:Parameter 1 of constructor in org.rongyilian.service.impl.Verifica ...

  9. Mybatis 报错`Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]`

    1.异常信息: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2] 这是因为mybatis的M ...

最新文章

  1. 配置SQL Server 2005 Express的身份验证方式,以及如何启用sa登录名。
  2. Python---进阶---logging---logger
  3. 读取一个文件,获取其中出现次数最多的前五个字符以及次数
  4. Element-UI分页组件使用——点第几页查第几页
  5. Redis02_数据模型初识
  6. 201507之佛山移动实习
  7. Laravel 使用firstOrCreate 报错MassAssignmentException
  8. WebGoat系列实验Buffer Overflows Code Quality Concurrency
  9. 如何去掉word中的回车符??
  10. 如何让素数分列C语言,哥德巴赫猜想栾生三生素数无限波林那克猜想两素数差证明,(定稿...
  11. keep-alive实现原理
  12. 两狗(sogou google)相争,必有一伤
  13. Python实现自省的方法有哪些?
  14. java我的世界114_我的世界114更新了什么_我的世界114更新内容_快吧单机游戏
  15. 三分钟部署Laxcus大数据管理系统
  16. Mixed-Integer Optimization with Constraint Learning
  17. 「生信练习题」从SnpEff注释得到的VCF中过滤4DTV位点
  18. 春招回忆录---雷火笔试
  19. android模拟器 报错:X Error of failed request: BadRequest (invalid request code or no such operation)
  20. Unity3d 技巧(4)-如何配置JavaHome

热门文章

  1. 《SEO实战密码》学习笔记之网站结构优化
  2. Visual Reasoning Strategies for Effect Size Judgments and Decisions
  3. 达梦数据库自动替换功能详解
  4. ggplot2-局部整体型图表
  5. 微软什么时候停止对win7进行服务器,微软官方通告:2020年1月24日起停止对windows7的技术支持...
  6. 李html画布,李雪松的绘画
  7. linux征途服务端,踏上Spring的征程3-Linux服务器从0开始搭建
  8. 【另一棵树的子树(572-java)】
  9. 新一代游戏服务端框架,该是什么样的?
  10. 小学美术计算机教案模板,小学美术教案模板