2015-10-21 49 views
0

我正在使用Spring XD创建流twittersearch,然后连线到我的tweet处理器,然后连接到日志。Spring XD Java配置不加载xml资源

我使用的Java配置类的所有罚款没有任何问题的话,我想用@ImportResource

@Configuration 
@ImportResource("config/applicationContext.xml") 
@EnableIntegration 
public class ModuleConfiguration { 

    @Bean 
    MessageChannel input() { 
     return new DirectChannel(); 
    } 

    @Bean 
    MessageChannel output() { 
     return new DirectChannel(); 
    } 

    @Autowired 
    TweetProcessor tweetProcessor; 

    @Bean 
    freemarker.template.Configuration configuration() { 
     return new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_23); 
    } 
} 

而且applicationContext.xml的内容添加的applicationContext.xml我ModuleConfiguration类:

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd"> 

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="locations"> 
      <list> 
       <value>file:/apps/conf/application.properties</value> 
      </list> 
     </property> 
    </bean> 

</beans> 

我的流定义:stream create --name JustCreate --definition“twittersearch --query = Java | tweet-processor | log”--deploy

当stre我部署了我的错误:

2015-10-21T11:26:26+0800 1.2.1.RELEASE WARN twitterSource-1-1 twitter.TwitterSearchChannelAdapter - Exception while reading stream. 
org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'singlenode:default,admin,singlenode,hsqldbServer:9393.JustCreate.0'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers 

我曾尝试使用也弹簧module.xml方法(不使用Java的配置在所有)和方法工作。

但我只是好奇Spring XD Java配置是否不支持@ImportResource注释。

谢谢。

回答

0

Spring XD一旦找到并解析配置资源,就会以普通正常方式从XML或@Configuration类创建应用程序上下文。 XD在config目录中查找。如果它找到.xml或或.groovy文件,它将使用该文件创建应用程序上下文。如果没有,它会查找一个.properties文件和一个base_packages属性来扫描@Configuration类。由于在配置目录中有一个XML文件,因此@Configuration被忽略。要导入资源,请将它们置于不同的路径中。这可以是配置的子目录或不同的顶级目录。这在Modules section of the XD reference guide中详细讨论。

+0

由于您的XML仅添加了PPC;你可以使用'@ PropertySource'来代替 - 查看[这个问题]的答案(http://stackoverflow.com/questions/33149198/spring-integration-spel-issues-with-annotation)。 –

+0

谢谢你们! – nanokernel