1

作为一个刚接触 Spring 但具有流处理背景的人,我对如何测试用 Spring Cloud Stream 编写的处理器感到非常困惑。测试文档(为 2.2.0 编写,但似乎是最新的,所以我猜对 3.0.7 仍然有效?)表明处理器应该通过注释自动装配到测试类中,但没有提到这个“处理器”在哪里豆来自。我试图通过以下方式提供它:

import org.springframework.cloud.stream.messaging.Processor;
...

@Autowired
private Processor processor;

但是在运行测试时,异常总是相同的:

Unsatisfied dependency expressed through field 'processor'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.stream.messaging.Processor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我什至在正确的道路上吗?在过去的一年中似乎有很多不推荐使用的功能,因此任何指向更新文档的指针都将不胜感激。

4

0 回答 0