2011-10-06 1 views
0

J'ai un adaptateur de canal de fichier qui doit écouter un répertoire dans des intervalles spécifiés. Et j'ai le code suivant.Configuration de la propriété System in Spring

<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> 

quand je REPLCE directory="file:${SYS.com.abc.wls.workdir}/finalize/ avec un vrai nom de répertoire (comme directory="file:C:/temp/finalize/) tout fonctionne très bien. Mais la propriété système est définie lors du démarrage du serveur, mais le ressort ne détecte pas la propriété système.

Pourriez-vous m'aider s'il vous plaît?

Mise à jour:

Je la configuration suivante pour porte lieu

<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> 

Suppression: file: de directory="file:${SYS.com.abc.wls.workdir}/finalize/" et changé à auto-create-directory="false" et maintenant je suis gettign l'exception comme ci-dessous,

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 

Répondre

1

Vous devez déclarer une entité de ressort reconnaissant izes les propriétés du système. L'approche typique consiste à mettre un PropertyPlaceHolderConfigurer dans votre configuration Spring.

Le mode par défaut est SYSTEM_PROPERTIES_MODE_FALLBACK, ce qui signifie que les valeurs qui ne sont pas conservées par le configurateur seront considérées comme une propriété système. Le mode peut être remplacé en utilisant setSystemPropertiesMode.

+0

@ Johan Sjöberg. Vous voulez dire que je devrais définir en tant que SYSTEM_PROPERTIES_MODE_FALLBACK dans PropertyPlaceholderConfigure? – nobody

+0

@ personne, j'ai modifié mon message pour être plus clair. –

+0

Je l'ai déjà fait. Mise à jour de la question – nobody