代码之家  ›  专栏  ›  技术社区  ›  Rustavil Nurkaev

在我的测试中,如何从spring云流中获取通道对象

  •  1
  • Rustavil Nurkaev  · 技术社区  · 8 年前

    我在下面定义了一个TestChannel接口

    public interface TestChannel {
        String CHANNEL_NAME = "test.channel";
    
        @Input(value = CHANNEL_NAME)
        SubscribableChannel channel();
    }
    

    我试着在测试中自动连接这个通道。

    @SpringBootTest
    public class TestChannelHandlerTest extends BaseTest {
    
        @Autowired
        private TestChannel testChannel;
    
        @Test
        public void someTest() {
        ...
        }
    }
    

    但是 TestChannel 未找到中的bean。我的问题是:如何自动连接任何通道。

    2 回复  |  直到 8 年前
        1
  •  0
  •   Gary Russell    8 年前

    添加 @Qualifier("test.channel") @Autowired .

    testChannel .

        2
  •  0
  •   dturanski    8 年前

    推荐文章