-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Clarify the effect of ordering auto-configuration #22337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@cfieber thanks for the report and the sample.
That's the wrong expectation. The auto-configuration order is about If some initialization order is required, you need to tell the context via |
I think we should improve the javadoc of the |
This moves archaius config back to being a BeanPostProcessor to ensure it happens early in the lifecycle. I had made some bad assumptions around autoconfig ordering via the annotations that were clarified here: spring-projects/spring-boot#22337
thanks so much for the quick response! |
This moves archaius config back to being a BeanPostProcessor to ensure it happens early in the lifecycle. I had made some bad assumptions around autoconfig ordering via the annotations that were clarified here: spring-projects/spring-boot#22337
This moves archaius config back to being a BeanPostProcessor to ensure it happens early in the lifecycle. I had made some bad assumptions around autoconfig ordering via the annotations that were clarified here: spring-projects/spring-boot#22337
I have two AutoConfiguration classes, with an ordering dependency defined via
@AutoConfigureBefore
but no direct dependency between them (setting up some legacy libraries that have not great static initialization and implicit static dependencies between themselves).I have also added
@AutoConfigurationOrder
trying to resolve that and observed the same behaviors. I left that out in my sample.In the absence of any dependency, the two autoconfigurations run in the order defined by the
@AutoConfigureBefore
and the components are successfully instantiated.However, if any component in the app adds a dependency on a component from the second autoconfiguration, that component is created and injected before any components in the first autoconfiguration are created.
This repo demonstrates the failure case:
https://github.com/cfieber/autoconfig-order
see https://github.com/cfieber/autoconfig-order/blob/master/bootapp/src/test/java/bootapp/BreakyTest.java specifically
Observed on both spring-boot
2.2.6.RELEASE
and2.3.1.RELEASE
I believe I can work around this problem by making the initializing component in the first autoconfiguration a bean post processor or something to cause it to initialize early, however that feels a bit heavy handed and less obvious than expressing the dependency with the autoconfiguration orderings.
The two autoconfigurations do not have direct dependencies (or even
@DependsOn
references) because there are a few different ways to configure the first dependency so I don't want a direct reference there.The text was updated successfully, but these errors were encountered: