I like to run my unit test with test spring profile without consul. I'm trying to use spring.cloud.config.enabled:false
and disabling EnableDiscoveryClient
annotation for test profile but it doesn't work.
I'm using spring.cloud.consul 1.0.0.BUILD-SNAPSHOT
.
Here is the exception:
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused: connect at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:87) at com.ecwid.consul.transport.DefaultHttpTransport.makeGetRequest(DefaultHttpTransport.java:46) at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:66)
I use @IntegrationTest({"spring. cloud. consul. enabled=false"}) tag to disable consul for my tests, as a class tag.
Spring Cloud Consul provides Consul integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.
cloud. consul. host property is pointing to 127.0. 0.1 and port to 8500 by default.
Try disabling Consul with spring.cloud.consul.enabled:false
in your profile.
I use @IntegrationTest({"spring.cloud.consul.enabled=false"})
tag to disable consul for my tests, as a class tag. I found that on the Spring Cloud Consul GitHub issue tracker, here.
The other suggestion from that post was to use something like the following as your bootstrap.yml
.
spring:
application:
name: <myServiceName>
cloud:
bus:
enabled: false
discovery:
enabled: false
consul:
enabled: false
config:
enabled: false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With