简体   繁体   中英

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. 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?

add spring-cloud-stream-test-support to 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. 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. In your case we talk about RabbitServiceAutoConfiguration :

@SpringBootTest
@ImportAutoConfiguration(exclude = RabbitServiceAutoConfiguration.class)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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