@AutoConfiguration
,因为它更方便。 nove,似乎没有一种方法来描述应应用属性源的顺序。我尝试将它们放在
@AutoConfigureBefore
课上,并使用
@AutoConfigureAfter
和@Configuration
。我尝试将它们放在普通的
@Configuration
课上,并从自动配置中导入
spring-core
。但是这些都没有产生可预见的顺序。同样,代码本身在
addLast
'中添加了第一个使用@PropertySource
看到的属性源,然后在此之前添加每个susequent源。请参阅下面的相关部分的图像屏幕截图:
this最终以一些奇怪的反向顺序从第一个看来,这使我更加困惑。
您可以建议在使用自动配置时如何实现订单?
javadoc说:
In certain situations, it may not be possible or practical to tightly control property source ordering when using @PropertySource annotations. For example, if the @Configuration classes above were registered via component-scanning, the ordering is difficult to predict. In such cases — and if overriding is important — it is recommended that the user fall back to using the programmatic PropertySource API. See ConfigurableEnvironment and MutablePropertySources javadocs for details.
为了确定属性源的各自顺序,可以使用