Cle*_*Dev 5 java configuration spring spring-boot
有人可以说明spring.application.index财产的用途是什么,为什么我们需要它?
Application.yml:
spring:
application:
name: ServiceName
index:
Run Code Online (Sandbox Code Playgroud)
据我所知,spring.application.index该版本从版本开始就已被弃用2.0.0.RC1。我通过比较以下这些附录来判断:
2.0.0.M7:常见的应用性能,其中spring.application.index被提及。2.0.0.RC1:常见的应用程序属性,spring.application.index未提及。通过检查ContextIdApplicationContextInitializer以下版本的源代码可以证明上述陈述:
版本2.0.0.M7 ContextIdApplicationContextInitializer。这些版本在自定义用于ApplicationContextID创建的应用程序索引方面提供了更多的可变性。
/**
* Placeholder pattern to resolve for application index. The following order is used
* to find the name:
* <ul>
* <li>{@code vcap.application.instance_index}</li>
* <li>{@code spring.application.index}</li>
* <li>{@code server.port}</li>
* <li>{@code PORT}</li>
* </ul>
* This order favors a platform defined index over any user defined value.
*/`"${vcap.application.instance_index:${spring.application.index:${server.port:${PORT:null}}}}"`
Run Code Online (Sandbox Code Playgroud)版本2.0.0.RC1 ContextIdApplicationContextInitializer。可以发现使用自动使用可以使索引递增AtomicLong,这也确保了索引的唯一性。请参阅内部ContextIdApplicationContextInitializer$ContextId类以获取源代码中的更多详细信息。关键方法是其构造函数:
ContextId createChildId() {
return new ContextId(this.id + "-" + this.children.incrementAndGet());
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
160 次 |
| 最近记录: |