Skip to content

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

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.

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

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