gpt4 book ai didi

java - 如何 Autowiring Spring Stream 云绑定(bind)

转载 作者:行者123 更新时间:2023-12-01 20:13:22 26 4
gpt4 key购买 nike

我在 application.yml 中定义了 errornotification 绑定(bind)

cloud:
stream:
bindings:
error:
destination: error
binder: default
notification:
destination: notification
binder: default

如何在我的组件中获取这些 bean?

我尝试过这种方法:

@Component
class MyComponent {

@Autowired
@Qualified("notification")
MessageChannel notificationChannel;
}

但是找不到notificationChanel

更新cloud.stream.bindings.* 仅允许配置 channel 。但不创建它。

最佳答案

您确定您有@EnableBinding和适当的接口(interface)来声明@Input@Output吗?

https://docs.spring.io/spring-cloud-stream/docs/Chelsea.SR2/reference/htmlsingle/index.html#_declaring_and_binding_channels

public interface Barista {

@Input
SubscribableChannel orders();

@Output
MessageChannel hotDrinks();

@Output
MessageChannel coldDrinks();
}

...
@EnableBinding(Barista.class)
public class CafeConfiguration {

关于java - 如何 Autowiring Spring Stream 云绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46304262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com