Issue
We have upgraded to 2.6 Spring boot version. We are also using Spring's Integration (org.springframework.boot:spring-boot-starter-integration).
When we try to start up the application we get:
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
┌──->──┐
| org.springframework.integration.internalPublisherAnnotationBeanPostProcessor
└──<-──┘
We were able to repro the issue with a clean Spring boot application:
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'
}
Does anyone have a hint of what might go wrong? Maybe some additional configuration is missing
Solution
Has been fixed recently: https://github.com/spring-projects/spring-integration/issues/3694.
Will be released next week for upcoming Spring Boot 2.6.2
.
As a workaround, instead of @EnablePublisher
you can add this bean:
@Bean(IntegrationContextUtils.PUBLISHER_ANNOTATION_POSTPROCESSOR_NAME)
static PublisherAnnotationBeanPostProcessor publisherAnnotationBeanPostProcessor() {
return new PublisherAnnotationBeanPostProcessor() {
@Override
public void afterPropertiesSet() {
}
};
}
It's problem that it has that this.beanFactory.getBean(PublisherAnnotationBeanPostProcessor.class)
in its afterPropertiesSet()
. So, to mitigate a cycle we just need to get rid of it!
Answered By - Artem Bilan
Answer Checked By - David Goodson (JavaFixing Volunteer)