Skip to content

2.6.0使用demo样例代码无法启动,报各种错 #4

Closed

Description

@qinxingnet

spring boot 2.6.0 按你给到的版本运行sample时:

Description:

Parameter 2 of method disruptor in com.lmax.disruptor.spring.boot.DisruptorAutoConfiguration required a single bean, but 2 were found:
	- applicationTaskExecutor: defined by method 'applicationTaskExecutor' in class path resource [org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.class]
	- taskScheduler: defined by method 'taskScheduler' in class path resource [org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.class]

按程序提示手动加入:

 @Primary
    @Bean(
            name = {"applicationTaskExecutor", "taskExecutor"}
    )
    @ConditionalOnMissingBean({Executor.class})
    public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {
        return builder.build();
    }

又报错:

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

Description:

The dependencies of some of the beans in the application context form a cycle:

┌─────┐
|  disruptorConfig (field protected com.lmax.disruptor.dsl.Disruptor com.lmax.disruptor.spring.boot.config.DisruptorConfig.disruptor)
↑     ↓
|  disruptor defined in class path resource [com/lmax/disruptor/spring/boot/DisruptorAutoConfiguration.class]
└─────┘

于是关掉循环依赖:

  main:
    allow-circular-references: true
    allow-bean-definition-overriding: true

还是报错:

org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'disruptorConfig': Bean with name 'disruptorConfig' has been injected into other beans [applicationTaskExecutor] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example.

请问哥们是怎么跑起来的?我试了半天都不行?

Activity

  1. loong10k commented on Sep 7, 2022

    @loong10k
    Collaborator
  2. dyrnq commented on Jan 4, 2024

    @dyrnq

    @qinxingnet
    改两个地方可以,

    	@Bean()
    	@ConditionalOnMissingBean(name="disruptorThreadFactory")
    	public ThreadFactory disruptorThreadFactory() {
    		return new DisruptorEventThreadFactory();
    	}
    
    
    	@Bean
    	@ConditionalOnClass({ Disruptor.class })
    	@ConditionalOnProperty(prefix = DisruptorProperties.PREFIX, value = "enabled", havingValue = "true")
    	public Disruptor<DisruptorEvent> disruptor(
    			DisruptorProperties properties, 
    			WaitStrategy waitStrategy,
    			@Qualifier("disruptorThreadFactory")
    			ThreadFactory threadFactory, 
    			EventFactory<DisruptorEvent> eventFactory,
    			@Qualifier("disruptorEventHandlers") 
    			List<DisruptorEventDispatcher> disruptorEventHandlers) {
    
    
    

    由于 @ConditionalOnMissingBean 啥也不写,默认是按照接口来判断的,所以这边没有创建,但是那边会有俩提供者 "applicationTaskExecutor", "taskExecutor"
    参考 https://blog.csdn.net/killerofjava/article/details/104515684

  3. dyrnq commented on Jan 4, 2024

    @dyrnq

    @hiwepy 多谢回复,我看和这个issues重复了,在这里写了下我的修改之处,不知道对不对,请大佬指正。

  4. loong10k commented on Nov 17, 2026

    @loong10k
    Collaborator

    Boot 2 修复已在 PR #10 的 feature 分支完成并通过 JDK 8 本地 mvn clean verify(8 个测试、90.31% 行覆盖率)及 GitHub Actions 44158307640。测试复现两个 Executor Bean 同时存在时的启动,另修复事件发布者注入与处理器顺序。原报告应用的完整配置不可用,因此无法声称逐项复现其循环依赖;待 2.7.x 按版本分支流程推广后再关闭 Issue。

  5. loong10k commented on Nov 17, 2026

    @loong10k
    Collaborator

    Resolution is now on feature/REQ-20261117-wandl-disruptor-boot2 and has passed feature → test/20261118 via PR #10. The test branch push and test → 2.7.x draft PR #11 both passed JDK 8 CI (eight tests; existing 90% JaCoCo gate unchanged). The issue remains open until the final version-line promotion decision and merge.

  6. loong10k commented on Nov 17, 2026

    @loong10k
    Collaborator

    已在独立功能分支 feature/REQ-20261118-wandl-disruptor-boot26-startup 修复 Boot 2.6 主线,并创建草稿 PR #12:#12

    • 将 disruptor-extension 依赖及代码调用对齐到当前 io.github.easy4j API,修复原主线无法编译、启动的问题。
    • 恢复真实执行的 Spring Boot 2.6.15 启动测试,新增 publisher 注入、一对一事件路由及处理顺序回归测试;本地 JDK 8 mvn clean verify 共 4 个测试通过。
    • 对应提交 fdd0586a34e0eb02fbd9616d147d579cf4f2eb5f 的远端 JDK 8 CI 已通过:https://github.com/easy-4-java/disruptor-spring-boot-starter/actions/runs/44194488174

    当前 PR 是验证用草稿。仓库已有 test/20261118 承载不兼容的 Boot 2.7 变更,因此 2.6 修复尚未按 feature → 独立 test → main 合并;Issue 保持开放直至主线合入并验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions