【问题标题】:How to disable spring cloud zookeeper when executing integration test执行集成测试时如何禁用spring cloud zookeeper
【发布时间】:2019-09-24 23:40:38
【问题描述】:

当我使用 TestRestTemplatespring-cloud-zookeeper-discovery 依赖项测试我的代码时,集成测试会尝试连接到 zookeeper。如果 zookeeper 没有运行,测试会抛出异常。

这是一个简单的项目,您可以在其中重现问题https://github.com/DenisGlot/disable-zookeeper-when-testing

如何让测试跳过连接到 zookeeper 部分?

【问题讨论】:

    标签: java spring-boot spring-cloud spring-cloud-zookeeper


    【解决方案1】:

    在 test/java/resources 中添加 bootstrap.properties 并放在那里

    spring.cloud.service-registry.auto-registration.enabled=false
    spring.cloud.zookeeper.discovery.enabled=false
    spring.cloud.zookeeper.discovery.register=false
    

    【讨论】:

      猜你喜欢
      • 2019-01-19
      • 2016-06-12
      • 2018-05-04
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      相关资源
      最近更新 更多