简体   繁体   English

禁用 Spring Cloud Stream Rabbit 进行测试

[英]Disable Spring Cloud Stream Rabbit for tests

I use:我用:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        <version>3.0.1.RELEASE</version>
    </dependency>

I need to disable Rabbit for testing the application.我需要禁用 Rabbit 来测试应用程序。 I tried this:我试过这个:

spring:
    cloud:
       config:
           enabled: false
           discovery:
               enabled: false

It didn't work.它没有用。

What do I need to do to prevent the Rabbit components from starting?我需要做什么来防止 Rabbit 组件启动?

add spring-cloud-stream-test-support to pom.xml将 spring-cloud-stream-test-support 添加到 pom.xml

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream-test-support</artifactId>
    <version>3.0.1.RELEASE</version>
    <scope>test</scope>
</dependency>

There is no such an option like disable for Spring Cloud Stream.没有像disable Spring Cloud Stream 这样的选项。 As far as I know only the way to prevent Spring Cloud Stream to start in test environment is to exclude an appropriate Binder auto-configuration.据我所知,阻止 Spring Cloud Stream 在测试环境中启动的唯一方法是排除适当的 Binder 自动配置。 In your case we talk about RabbitServiceAutoConfiguration :在您的情况下,我们谈论RabbitServiceAutoConfiguration

@SpringBootTest
@ImportAutoConfiguration(exclude = RabbitServiceAutoConfiguration.class)

@SpringBootApplication(exclude = { BindingServiceConfiguration.class, FunctionConfiguration.class // spring-cloud-starter-stream-rabbit })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM