运行示例源时Spring Spring数据流DestinationReslutionException

时间:2016-12-09 15:01:12

标签: spring apache-kafka spring-cloud-stream spring-cloud-dataflow

我在运行示例spring-cloud-dataflow源应用程序时遇到问题。应用程序以代码0退出(它应该正常工作)。我调试它并注意到抛出异常后:

DestinationResolutionException: failed to look up MessageChannel with name 'output'

我按照入门指南http://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/index.html#_getting_started进行操作,但我无法使用它。 我做了什么: - 我有动物园管理员工作; - 我有kafka工作;

代码:

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.annotation.InboundChannelAdapter;

@EnableBinding(Source.class)
public class SampleSource {

    @InboundChannelAdapter(Source.OUTPUT)
    public String greet() {
        return "hello world " + System.currentTimeMillis();
    }
}

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class SampleSourceApplication {

    public static void main(String[] args) {
        try (ConfigurableApplicationContext run = SpringApplication.run(SampleSourceApplication.class, args)) {
        }
    }
}

pom:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.2.RELEASE</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>  
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-kafka</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

命令行参数: - spring.cloud.stream.bindings.output.destination = test

我可以提供有关例外的更多详细信息:

org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'output' in the BeanFactory.; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.stream.messaging.Source': Initialization of bean failed; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.stream.config.ChannelBindingServiceConfiguration': Initialization of bean failed; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties': Initialization of bean failed; 
nested exception is java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2ef14fe has been closed already

1 个答案:

答案 0 :(得分:0)

主应用程序似乎没有导入类SampleSource。 您确定SampleSource类与SampleSourceApplication的包在同一个包中吗?