2015-10-15 73 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