找不到带限定符的bean。找不到MessageChannel Bean

时间:2017-10-03 14:47:05

标签: spring-cloud-stream

我无法使用以下代码。我收到以下错误 在HelloController类中找不到带限定符“messages”的bean。

我有以下依赖

  • 弹簧云流 - 粘合剂 - 卡夫卡
  • 弹簧引导起动集成
  • 弹簧引导起动的Web
package com.example.scs.demoscs;

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

@SpringBootApplication
public class DemoScsApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoScsApplication.class, args);
    }
}
package com.example.scs.demoscs;

import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;


public interface DemoMessages {

    @Output("messages")
    MessageChannel messages();

}
package com.example.scs.demoscs;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableBinding(DemoMessages.class)
public class ChannelConfiguration {

}
package com.example.scs.demoscs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.messaging.MessageChannel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
public class HelloController {

    private MessageChannel output;

    @Autowired
    public HelloController(@Qualifier("messages") MessageChannel output) {
        this.output = output;
    }

    @GetMapping("/hello")
    public String SayHello(){

        return "Hello";
    }
}

0 个答案:

没有答案