Spring/システムプロパティを設定する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
<?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/c...
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/sch...
http://www.springframework.org/schema/util http://www....
http://www.springframework.org/schema/context http://w...
<context:annotation-config />
<context:component-scan base-package="xxx" />
<import resource="META-INF/spring/test-datasource-cont...
<bean
class="org.springframework.beans.factory.config.Meth...
<property
name="targetObject">
<!-- System.getProperties() -->
<bean
class="org.springframework.beans.factory.con...
<property name="targetClass" value="java.lan...
<property name="targetMethod" value="getProp...
</bean>
</property>
<property
name="targetMethod"
value="putAll" />
<property
name="arguments">
<!-- The new Properties -->
<util:properties>
<prop key="key1">value1</prop>
<prop key="key2">value2</prop>
</util:properties>
</property>
</bean>
</beans>
とかなり仰々しく設定することで、
System.getProperty("key1");
で値が取れるようになります。。
終了行:
<?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/c...
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/sch...
http://www.springframework.org/schema/util http://www....
http://www.springframework.org/schema/context http://w...
<context:annotation-config />
<context:component-scan base-package="xxx" />
<import resource="META-INF/spring/test-datasource-cont...
<bean
class="org.springframework.beans.factory.config.Meth...
<property
name="targetObject">
<!-- System.getProperties() -->
<bean
class="org.springframework.beans.factory.con...
<property name="targetClass" value="java.lan...
<property name="targetMethod" value="getProp...
</bean>
</property>
<property
name="targetMethod"
value="putAll" />
<property
name="arguments">
<!-- The new Properties -->
<util:properties>
<prop key="key1">value1</prop>
<prop key="key2">value2</prop>
</util:properties>
</property>
</bean>
</beans>
とかなり仰々しく設定することで、
System.getProperty("key1");
で値が取れるようになります。。
ページ名: