Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 在bootstrap.yml中禁用ZooKeeper,它在测试期间仍然运行_Spring_Spring Boot_Spring Cloud Zookeeper - Fatal编程技术网

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

Spring 在bootstrap.yml中禁用ZooKeeper,它在测试期间仍然运行,spring,spring-boot,spring-cloud-zookeeper,Spring,Spring Boot,Spring Cloud Zookeeper,我正在运行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.dis

我正在运行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

        
pom:

ZooKeeper仍尝试连接“live”:

我想为集成测试禁用所有zookeeper引导操作。我很沮丧,也不知道怎么了:为什么动物园管理员在我禁用它的时候还在试着跑呢?提前谢谢。

这应该行得通

spring.cloud.zookeeper.enabled=false
对于
yaml

spring:
  cloud:
    zookeeper:
        enabled: false

尝试过之后,yml使用“:”而不是“=”。我使bootstrap-test.yml仅保持:spring.cloud.zookeeper.config.enabled:false。Zookeeper仍在运行。@Alpha_Omega我认为对于
yaml
,您需要放入嵌套结构,而不是内联结构。(每一个都由选项卡空间嵌套)它仍然不起作用,这真的很奇怪。关于stackoverflow的其他回答清楚地说明了这应该是有效的。我怎么才能知道Spring是否正在使用我的引导配置呢?天哪,你是个天才,谢谢:)
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)
spring.cloud.zookeeper.enabled=false
spring:
  cloud:
    zookeeper:
        enabled: false