【问题标题】:Spring Boot 2.6 + Integration - internalPublisherAnnotationBeanPostProcessor circular dependencySpring Boot 2.6 + 集成 - internalPublisherAnnotationBeanPostProcessor 循环依赖
【发布时间】:2022-01-18 19:54:14
【问题描述】:

我们已经升级到 2.6 Spring boot 版本。 我们也在使用 Spring 的 Integration (org.springframework.boot:spring-boot-starter-integration)。

当我们尝试启动我们得到的应用程序时:

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

Description:

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

┌──->──┐
|  org.springframework.integration.internalPublisherAnnotationBeanPostProcessor
└──<-──┘

我们能够使用干净的 Spring 启动应用程序重现该问题:

DemoApplication.java

package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.config.EnablePublisher;

@EnableIntegration
@EnablePublisher
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

build.gradle

plugins {
    id 'org.springframework.boot' version '2.6.1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

有没有人暗示可能出了什么问题?可能缺少一些额外的配置

【问题讨论】:

    标签: java spring spring-boot spring-integration


    【解决方案1】:

    最近已修复:https://github.com/spring-projects/spring-integration/issues/3694

    将于下周发布,用于即将推出的 Spring Boot 2.6.2

    作为一种解决方法,您可以添加此 bean,而不是 @EnablePublisher

    @Bean(IntegrationContextUtils.PUBLISHER_ANNOTATION_POSTPROCESSOR_NAME)
    static PublisherAnnotationBeanPostProcessor publisherAnnotationBeanPostProcessor() {
        return new PublisherAnnotationBeanPostProcessor() {
    
            @Override
            public void afterPropertiesSet() {
    
            }
    
        };
    }
    

    问题在于它的this.beanFactory.getBean(PublisherAnnotationBeanPostProcessor.class) 中有afterPropertiesSet()。所以,为了缓解一个循环,我们只需要摆脱它!

    【讨论】:

    • 有道理,谢谢解答!
    猜你喜欢
    • 2020-07-15
    • 2015-05-17
    • 1970-01-01
    • 1970-01-01
    • 2020-09-25
    • 2018-09-21
    • 1970-01-01
    • 2020-02-18
    • 1970-01-01
    相关资源
    最近更新 更多