0

I have multiple applications that share the same configuration classes and once with spring boot v3 I received multiple circular dependencies errors. Most of them were legit mistakes from my side and I manage to refactor the code and fix them, but now I'm stuck with the following message for all the applications:


   webHandler defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration$EnableWebFluxConfiguration.class]
      ↓
   healthEndpointWebFluxHandlerMapping defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointReactiveWebExtensionConfiguration$WebFluxAdditionalHealthEndpointPathsConfiguration.class]
┌─────┐
|  healthEndpoint defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]
↑     ↓
|  healthContributorRegistry defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]
↑     ↓
|  mongoHealthContributor defined in class path resource [org/springframework/boot/actuate/autoconfigure/data/mongo/MongoReactiveHealthContributorAutoConfiguration.class]
↑     ↓
|  reactiveMongoTemplate defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]
↑     ↓
|  mappingMongoConverter defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]
↑     ↓
|  mongoMappingContext defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataConfiguration.class]
↑     ↓
|  consulAutoServiceRegistrationListener defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulAutoServiceRegistrationAutoConfiguration.class]
↑     ↓
|  consulAutoServiceRegistration defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulAutoServiceRegistrationAutoConfiguration.class]
↑     ↓
|  consulServiceRegistry defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulServiceRegistryAutoConfiguration.class]
↑     ↓
|  ttlScheduler defined in class path resource [org/springframework/cloud/consul/support/ConsulHeartbeatAutoConfiguration.class]
↑     ↓
|  actuatorHealthStatusProvider defined in class path resource [org/springframework/cloud/consul/support/ConsulHeartbeatAutoConfiguration$ActuatorBasedApplicationStatusProviderConfig.class]
└─────┘


Not sure exactly how to proceed from here as I have no idea what it's actually casing this chain of dependencies.

I tried to remove the consul components and let only the default configuration, but without any luck.

r.m.ghimis
  • 33
  • 1
  • 5
  • Can you share the failure when you've removed the Consul components? – Andy Wilkinson Jul 21 '23 at 14:03
  • Removing everything that's related to consul from dependency tree made the application run successfully. I had only two nested dependencies from consul: `org.springframework.cloud:spring-cloud-consul-discovery` and `com.ecwid.consul:consul-api`. Also I have consul heartbeat enabled via properties: `spring.cloud.consul.heartbeat.enabled=true` and if I disabled it everything works properly(with the consul dependencies included) – r.m.ghimis Jul 21 '23 at 14:25
  • Can you share a minimal, reproducible example? The link between `mongoMappingContext` and `consulAutoServiceRegistrationListener` is surprising and I don't think it can be figured out without one. – Andy Wilkinson Jul 21 '23 at 15:46

1 Answers1

0

write something like this

@SpringBootApplication(exclude = MongoReactiveDataAutoConfiguration.class)

@Bean
@ConditionalOnMissingBean(ReactiveMongoDatabaseFactory.class)
public SimpleReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory(MongoProperties properties,
                                                                       MongoClient mongo) {
    String database = properties.getMongoClientDatabase();
    return new SimpleReactiveMongoDatabaseFactory(mongo, database);
}

 @Bean
public ReactiveMongoTemplate reactiveMongoTemplate(ReactiveMongoDatabaseFactory factory) {
    return new ReactiveMongoTemplate(factory);
}
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 29 '23 at 20:13