2015-10-15 52 views
2

Spring集成規劃環境地政司的問題,我有我fileMessageProvider()作爲與註釋

@InboundChannelAdapter(value = "files" , poller = @Poller( fixedDelay = "${my.poller.interval}", maxMessagesPerPoll = "1" )) 
public Message<File> fileMessageProvider() { 
    ... 
} 

給人NumberFormatException的部署後

Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPoller' defined in "../MyPoller.class": Initialization of bean failed; nested exception is java.lang.NumberFormatException: For input string: "{#my.poller.interval}" 

而是規劃環境地政司的如果我使用FIXEDDELAY = 「10000」,它的工作好。

我的Spring集成版 '4.0.0.RELEASE'

更新:1

我使用註釋和XML配置的混合

Batch.properties

my.poller.interval=20000 

integration-context.xml

<context:property-placeholder location="classpath:Batch.properties"/> 
<context:component-scan base-package="com.org.reader" /> 

<int:transformer input-channel="files" output-channel="requests"> 
    <bean class="com.org.reader.MyMessageToJobRequest"> 
     <property name="job" ref="addMessages"/> 
    </bean> 
</int:transformer> 
+0

嘗試使用#{} insted {#} – Fincio

+0

嘗試fixedDelay =「#{my.poller.interval}」 給出類似的異常java.lang.NumberFormatException:對於輸入字符串:「# {my.poller.interval}「 – Sam

+0

將#更改爲$。它應該看起來像'$ {my.poller.interval}'。當然,如果你有'my'對象具有具有'interval'屬性的'pooler'屬性,它就會起作用。 – wawek

回答

1

我們有類似的測試情況對此事並準確,因爲這個功能的提高:

@Override 
    @ServiceActivator(inputChannel = "input", outputChannel = "output", 
      poller = @Poller(maxMessagesPerPoll = "${poller.maxMessagesPerPoll}", fixedDelay = "${poller.interval}")) 
    @Publisher 
    @Payload("#args[0].toLowerCase()") 
    @Role("foo") 
    public String handle(String payload) { 
     return payload.toUpperCase(); 
    } 

不過是:我必須確認它停止,如果我們在XML中指定<context:property-placeholder>正常工作而不是@Configuration類中的@PropertySource

我不記得有關此問題的特定JIRA,但我記得使用註釋和XML配置混合,第一個優先,並且環境必須在@Configuration類中配置。

在我的示例,它看起來像:

@Configuration 
@ComponentScan 
@IntegrationComponentScan 
@EnableIntegration 
@PropertySource("classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties") 
@ImportResource("classpath:org/springframework/integration/configuration/EnableIntegrationTests-context.xml") 
@EnableMessageHistory({"input", "publishedChannel", "annotationTestService*"}) 
public class ContextConfiguration { 

    @Bean 
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { 
     return new PropertySourcesPlaceholderConfigurer(); 
    } 

} 

UPDATE

來自對岸,我發現如何使它從框架角度開展工作。

所以,這是一個錯誤,我正在提出關於此事的JIRA

謝謝你分享你的經驗!

+0

使用@PropertySource我的需求正在工作好。謝謝你的支持。我很高興我可以提出這個錯誤。 – Sam