根据this answerorg.springframework.batch.support.SystemPropertyInitializer
,您可以在Spring Context启动期间使用Spring Batch类设置系统属性。
特别是,我希望能够使用它来设置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
.
有可能实现这一目标吗?