繁体   English   中英

在 bootstrap.yml 中禁用 ZooKeeper,它在测试期间仍然运行

[英]Disabled ZooKeeper in bootstrap.yml, it still runs during testing

我正在运行一个 SpringBoot 应用程序。 我有 bootstrap-test.yml(位于 src/test/resources/config 下),如下所示:

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

        

起居室:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
    <version>2.2.2.RELEASE</version>
</dependency>

但是,当我尝试运行集成测试时:

@ActiveProfiles("test")
@DirtiesContext 
@SpringBootTest
public class TestClass......

ZooKeeper 仍然尝试“实时”连接:

16:02:14.752 [main] INFO  org.apache.zookeeper.ZooKeeper - Client environment:os.memory.free=493MB
16:02:14.752 [main] INFO  org.apache.zookeeper.ZooKeeper - Client environment:os.memory.max=8116MB
16:02:14.752 [main] INFO  org.apache.zookeeper.ZooKeeper - Client environment:os.memory.total=610MB
16:02:14.778 [main] INFO  o.a.c.f.imps.CuratorFrameworkImpl - Starting
16:02:14.783 [main] INFO  org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=localhost:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@76d828ff
16:02:14.788 [main] INFO  o.apache.zookeeper.ClientCnxnSocket - jute.maxbuffer value is 4194304 Bytes
16:02:14.798 [main-SendThread(localhost:2181)] INFO  org.apache.zookeeper.ClientCnxn - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
16:02:14.805 [main] INFO  o.a.c.f.imps.CuratorFrameworkImpl - Default schema
16:02:16.805 [main-SendThread(localhost:2181)] WARN  org.apache.zookeeper.ClientCnxn - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
    at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:779)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:357)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1214)

我想禁用所有 zookeeper 引导操作以进行集成测试。 什么给出了,我很沮丧,不知道出了什么问题:为什么当我禁用 Zookeeper 时它仍然试图运行? 提前致谢。

这应该工作!

spring.cloud.zookeeper.enabled=false

对于yaml

spring:
  cloud:
    zookeeper:
        enabled: false

暂无
暂无

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

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