ユーザーごとに異なるプロパティ セットを用意すると便利です。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder
location="classpath:/path/to/package/default.properties,
classpath:/path/to/package/#{ systemProperties['user.name'] }.properties"/>
</beans>
アプリケーションを実行すると、Spring は式を認識しません。コンテキストは開始されず、Spring は次のように言います。class path resource [path/to/package/#{ systemProperties['user.name'] }.properties] cannot be opened
式を手動で文字列に置き換えて有効なリソースにすると、動作は期待どおりになります。マニュアルには、それが機能するはずであると記載されています。
spring-context と spring-core (3.1.2-RELEASE) はクラスパスにあります。
- なぜ春は環境変数を取得しないのですか?
- 私は、同じ機能上の問題を解決する代替ソリューションを受け入れます。