英文:
Spring boot @Configuration order
问题
我有两个配置类,ConfigA 和 ConfigB,有没有办法按我想要的顺序加载这些配置类,我想要先加载 ConfigB 然后再加载类 ConfigA。请帮助我。
英文:
I have two configuration classes, ConfigA & ConfigB , Is there anyway that I can load those configuration classes in the order, I want ConfigB to be loaded first then load the class ConfigA. Please help me.
答案1
得分: 1
如果@Configuration
类被组件扫描,您不能可靠地控制它们的顺序,因此第一步是确保它们不被组件扫描。然后,您可以使用@Import
来导入配置类。它们将按照您在@Import
注解中列出的顺序进行处理。
英文:
If the @Configuration
classes are component-scanned you cannot reliably control their order so the first step is to ensure that they aren't component scanned. You can then use @Import
to import the configuration classes. They will be processed in the order in which you list them in the @Import
annotation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论