0
我有文件通道適配器,需要以指定的時間間隔偵聽目錄。我有以下代碼。在春季配置系統屬性
<file:inbound-channel-adapter id="fileAdapter"
directory="file:${SYS.com.abc.wls.workdir}/finalize/" queue-size="1000"
auto-startup="true" filename-pattern="*.txt">
<int:poller fixed-delay="500">
</int:poller>
</file:inbound-channel-adapter>
當我replce directory="file:${SYS.com.abc.wls.workdir}/finalize/
一個真正的目錄名稱(如directory="file:C:/temp/finalize/
)一切工作正常。但系統屬性是在啓動服務器時設置的,但是spring沒有檢測到系統屬性。
你能幫忙嗎?
更新:
我爲佔位
<beans:bean id="jobProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="properties">
<beans:value>
job.group.commit.interval=5000
</beans:value>
</beans:property>
<beans:property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK" />
<beans:property name="ignoreUnresolvablePlaceholders"
value="true" />
<beans:property name="order" value="1" />
</beans:bean>
以下配置中刪除:file:
從directory="file:${SYS.com.abc.wls.workdir}/finalize/"
並變更爲auto-create-directory="false"
,現在我gettign例外如下,
by: java.lang.IllegalArgumentException: Source directory **[${SYS.com.abc.wls.workdir}\finalize] does not exist**.
at org.springframework.util.Assert.isTrue(Assert.java:65)
at org.springframework.integration.file.FileReadingMessageSource.onInit(FileReadingMessageSource.java:233)
at org.springframework.integration.context.IntegrationObjectSupport.afterPropertiesSet(IntegrationObjectSupport.java:98)
at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.initSource(FileReadingMessageSourceFactoryBean.java:153)
at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.getObject(FileReadingMessageSourceFactoryBean.java:99)
at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.getObject(FileReadingMessageSourceFactoryBean.java:37)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$2.run(FactoryBeanRegistrySupport.java:133)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:131)
... 63 more
@ JohanSjöberg。你的意思是我應該在PropertyPlaceholderConfigure中將 設置爲SYSTEM_PROPERTIES_MODE_FALLBACK? –
nobody
@nobody,我編輯我的帖子更清晰。 –
我已經這樣做了。更新了問題。 – nobody