【发布时间】:2017-08-12 13:51:37
【问题描述】:
根据this answer,您可以在Spring Context启动期间使用Spring Batch类org.springframework.batch.support.SystemPropertyInitializer设置系统属性。
特别是,我希望能够使用它来设置 ENVIRONMENT,因为 Spring Batch 配置的一部分内容如下:
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>
<value>classpath:batch-default.properties</value>
<value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>
</list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="order" value="1" />
</bean>
但是SystemPropertyInitializer 使用afterPropertiesSet() 设置系统属性,显然这是在PropertyPlaceholderConfigurer 的配置之后发生的。
有可能实现吗?
【问题讨论】:
标签: java spring-batch spring-batch-admin system-properties property-placeholder