-
Notifications
You must be signed in to change notification settings - Fork 628
Description
Have the following warning log when starting:
2024-05-28T11:26:03.392+08:00 WARN 74763 --- [state-machine] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.statemachine.config.configuration.StateMachineAnnotationPostProcessorConfiguration' of type [org.springframework.statemachine.config.configuration.StateMachineAnnotationPostProcessorConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [org.springframework.statemachine.processor.stateMachineAnnotationPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
A possible solution:
Original code:
@Configuration
public class StateMachineAnnotationPostProcessorConfiguration {
private final static String POST_PROCESSOR_BEAN_ID = "org.springframework.statemachine.processor.stateMachineAnnotationPostProcessor";
@Bean(name = POST_PROCESSOR_BEAN_ID)
public StateMachineAnnotationPostProcessor springStateMachineAnnotationPostProcessor() {
return new StateMachineAnnotationPostProcessor();
}
}
New code:
public class StateMachineAnnotationPostProcessorConfiguration {
private final static String POST_PROCESSOR_BEAN_ID = "org.springframework.statemachine.processor.stateMachineAnnotationPostProcessor";
@Bean(name = POST_PROCESSOR_BEAN_ID)
public static StateMachineAnnotationPostProcessor springStateMachineAnnotationPostProcessor() {
return new StateMachineAnnotationPostProcessor();
}
}
SpringBoot considers StateMachineAnnotationPostProcessor
as a PostProcessor
. The creation of this bean necessitates the prior instantiation of the StateMachineAnnotationPostProcessorConfiguration
class. However, the instantiation of this class further requires all PostProcessor
s to process it, including StateMachineAnnotationPostProcessor
. Consequently, this results in a warning log indicating that some PostProcessor
s cannot process it. While it's true that the StateMachineAnnotationPostProcessorConfiguration
class does not actually require any PostProcessor
processing, SpringBoot is not intelligent enough to discern this. Though this warning is rather harmless, it can be somewhat bothersome to individuals with OCD😄.