【问题标题】:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commandGateway' defined in class path resourceorg.springframework.beans.factory.UnsatisfiedDependencyException:创建类路径资源中定义的名称为“commandGateway”的bean时出错
【发布时间】:2021-05-20 05:59:36
【问题描述】:

我正在将现有的 axon-core : 3.3.6 升级到 4.0.4 并在构建应用程序时遇到问题我该如何解决?

这是一个例外:

通过构造函数参数0表示的不满足的依赖关系; 嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException: 在类路径中定义名称为“commandGateway”的 bean 创建错误 资源 [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class]: 通过方法“commandGateway”表达的不满足的依赖关系 参数0;嵌套异常是 org.springframework.beans.factory.NoUniqueBeanDefinitionException: 否 'org.axonframework.commandhandling.CommandBus' 类型的限定 bean 可用:在候选者中发现了一个以上的“主要”bean: [commandBus,分布式CommandBus]

【问题讨论】:

标签: java spring-boot axon


【解决方案1】:

共享异常提到:

在候选中发现了多个“主要”bean:[commandBus, 分布式命令总线]

这可能意味着您的CommandBus bean 使用@Primary 注释。如果是这样,您可以删除该注释,因为 DistributedCommandBus 实例应该只作为主要实例。

如果不是这种情况,您可以通过显式配置CommandGateway 来解决问题。这样,您就可以覆盖 Axon 的自动配置,这显然难以解决要使用的“命令总线”。您要构建的类是DefaultCommandGateway,它引用CommandBus 作为网关。你可能想要注入DistributedCommandBus

最后,Axon 已经升级到 4.5 版。在此过程中进行了许多可能值得的改进。您遇到的一些自动配置问题也不太可能在某个中间版本中得到解决。

【讨论】:

    猜你喜欢
    • 2022-01-01
    • 1970-01-01
    • 2020-03-25
    • 2021-06-28
    • 2021-10-13
    • 2018-12-27
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多