Wrong behavior
When just putting the jar into the classpath (e.g. by adding a maven dependency), but not adding the @EnableNakadiProducer annotation, a spring-boot app will fail during the startup.
Error message:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping]: Factory method 'endpointHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcEndpoints' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'snapshotEventCreationMvcEndpoint' defined in class path resource [org/zalando/nakadiproducer/NakadiProducerAutoConfiguration$ManagementEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'snapshotEventCreationMvcEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'snapshotEventCreationEndpoint' defined in class path resource [org/zalando/nakadiproducer/NakadiProducerAutoConfiguration$ManagementEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'snapshotEventCreationEndpoint' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method snapshotEventCreationEndpoint in
org.zalando.nakadiproducer.NakadiProducerAutoConfiguration$ManagementEndpointConfiguration
required a bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService' that
could not be found.
Action:
Consider defining a bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService'
in your configuration.
Analysis
The main thing NakadiProducerAutoConfiguration is only activated when the @EnableNakadiProducer annotation is used. But it looks like the inner class ManagementEndpointConfiguration (which is annotated with @ManagementContextConfiguration) is used anyways (maybe just in some circumstances), and this fails because the SnapshotCreationService bean is then missing.
If my analysis above is correct, this should now be solved in the 20.0.0 release for spring-boot 2 (because that is not using the @ManagementContextConfiguration anymore).
Wrong behavior When just putting the jar into the classpath (e.g. by adding a maven dependency), but not adding the
@EnableNakadiProducer
annotation, a spring-boot app will fail during the startup.Error message:
Analysis
The main thing NakadiProducerAutoConfiguration is only activated when the
@EnableNakadiProducer
annotation is used. But it looks like the inner classManagementEndpointConfiguration
(which is annotated with@ManagementContextConfiguration
) is used anyways (maybe just in some circumstances), and this fails because the SnapshotCreationService bean is then missing.This might be related to the spring.factories file which mentions it.