2 回答

TA貢獻1793條經(jīng)驗 獲得超6個贊
據(jù)我所知,spring.application.index
自 version 以來已被認為已棄用2.0.0.RC1
。我通過比較以下這些附錄來判斷:
Spring Boot
2.0.0.M7
:提到的常見應(yīng)用程序?qū)傩浴?/a>spring.application.index
Spring Boot
2.0.0.RC1
:未提及的常見應(yīng)用程序?qū)傩浴?/a>spring.application.index
通過檢查ContextIdApplicationContextInitializer
這些版本的源代碼可以證明前面的說法:
版本
2.0.0.M7
ContextIdApplicationContextInitializer。這些版本在自定義用于 ApplicationContextID 創(chuàng)建的應(yīng)用程序索引方面提供了更多的可變性。
/**
* 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}}}}"`
版本2.0.0.RC1 ContextIdApplicationContextInitializer。可能會發(fā)現(xiàn)索引是自動遞增的 using AtomicLong,這也確保了它的唯一性。有關(guān)源代碼中的更多詳細信息,請參閱內(nèi)部ContextIdApplicationContextInitializer$ContextId類。關(guān)鍵方法是它的構(gòu)造函數(shù):
ContextId createChildId() {
return new ContextId(this.id + "-" + this.children.incrementAndGet());
}

TA貢獻1847條經(jīng)驗 獲得超11個贊
/**
* 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}}}}"`
版本2.0.0.RC1 ContextIdApplicationContextInitializer。可能會發(fā)現(xiàn)索引是自動遞增的 using AtomicLong,這也確保了它的唯一性。有關(guān)源代碼中的更多詳細信息,請參閱內(nèi)部ContextIdApplicationContextInitializer$ContextId類。關(guān)鍵方法是它的構(gòu)造函數(shù):
ContextId createChildId() {
return new ContextId(this.id + "-" + this.children.incrementAndGet());
}
添加回答
舉報