[英]Spring.Net \ DI \ How to read system environment variable
在我的依賴項注入配置文件中-我不知道(也找不到示例)如何將一些預定義的環境變量文件設置為成員。
在Spring.Net中無法說出如何做-您的幫助將不勝感激。
使用EnvironmentVariableSource
,當前缺少一些當前文檔: http : //springframework.net/docs/1.3.2/reference/html/objects.html#objects-variablesource 。 我寫了一些其他文檔,它們可能會包含在構建的下一個2.0版本中。 同時,您還可以在Github上查看以下示例代碼https://github.com/serra/spring-net-examples/tree/master/Spring.IoCQuickStart.VariableSources 。
看一下VariablePlaceholderConfigurer
對象。 它應該可以完成這項工作: http : //www.springframework.net/doc-latest/reference/html/objects.html#objects-variablesource
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
<property name="VariableSources">
<list>
<object type="Spring.Objects.Factory.Config.EnvironmentVariableSource, Spring.Core"/>
</list>
</property>
</object>
<object type="MyObject">
<property name="MyProperty" value="${MyEnvironmentVariableName}"/>
</object>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.