部署自定义Spring XD处理器时出错

时间:2015-12-18 07:38:20

标签: java spring spring-xd

我有一个自定义处理器,我已经在示例推文变换器之后建模了。使用此处理器部署流后,出现以下错误:

2015-12-18T08:27:17+0100 1.3.0.RELEASE ERROR DeploymentsPathChildrenCache-0 container.DeploymentListener - Exception deploying module
java.lang.IllegalArgumentException: Required module artifacts are either missing or invalid. Unable to determine module type for module definition
: 'processor:my-own-processor'.

我有一个ModuleConfiguration.java,看起来像这样(减去导入)

package com.my.package.myprocessor;

@Configuration
@EnableIntegration
public class ModuleConfiguration {
    @Bean
    MessageChannel input() {
        return new DirectChannel();
    }
    @Bean
    MessageChannel output() {
        return new DirectChannel();
    }

    @Bean
    MyProcessor transformer() {
        return new MyProcessor();
    }
}

处理器本身如下所示:

package com.my.package.myprocessor;

@MessageEndpoint
public class MyProcessor {

   MyProcessor() {
      // do some initialization      
   }

   @Transformer( inputChannel = "input", outputChannel = "output" )
   public String transform( String payload ) 
   {
      return "Hello World!";
   }
}

我还在src / main / resources下添加了一个spring-module.properties和一个spring-module.xml。两者都被复制到生成的jar文件中的resources / - 我在mvn包之后检查了它。

spring-module.properties很简单:

base_packages=com.my.package.myprocessor

并且spring-module.xml声明与模块配置相同:

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

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

    <transformer input-channel="input" output-channel="output">
        <beans:bean class="com.my.package.myprocessor.MyProcessor"/>
    </transformer>

    <channel id="output"/>
</beans:beans>

我上传了这样的模块:

module upload --file ~/Programs/my-processor/target/my-processor-1.0.0.BUILD-SNAPSHOT-runtime-dependencies.jar --name my-processor --type processor

并创建了这样的流:

stream create --name my-processor --definition "input: file --mode=lines | aixigo-vgm | output: file" --deploy

我做错了什么?

1 个答案:

答案 0 :(得分:1)

问题确实是包装。我现在选择使用spring boot插件来打包这样的超级jar:

<build>
  <plugins>
     <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>1.3.0.RELEASE</version>
        <configuration>
           <layout>MODULE</layout>
        </configuration>
        <executions>
           <execution>
              <goals>
                 <goal>repackage</goal>
              </goals>
           </execution>
        </executions>
     </plugin>
  </plugins>
</build>

这里最重要的是MODULE布局。这在XD文档中提到过,但在别处很难记录。