I have this microservice which is a discovery client:
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I know that if it is tried to be started while the discovery server is not yet available, it will fail. I would like to know if there is a way to start the application even if the discovery server is still not available. The issue arose when I ran JUnit unit test for this during build. I am encountering the following stack trace snippet during startup/start of JUnit tests: (by the way, unit tests have nothing to do with service Discovery)
2016-03-07 14:45:54.741 ERROR 3024 --- [ main] o.s.boot.SpringApplication : Application startup failed
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:80) ~[consul-api-1.1.8.jar:na] at com.ecwid.consul.transport.AbstractHttpTransport.makeGetRequest(AbstractHttpTransport.java:39) ~[consul-api-1.1.8.jar:na] at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:81) ~[consul-api-1.1.8.jar:na] at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:150) ~[consul-api-1.1.8.jar:na] at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:143) ~[consul-api-1.1.8.jar:na] at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:394) ~[consul-api-1.1.8.jar:na] at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:63) ~[spring-cloud-consul-config-1.0.0.M6.jar:1.0.0.M6] at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:74) ~[spring-cloud-consul-config-1.0.0.M6.jar:1.0.0.M6] at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89) ~[spring-cloud-context-1.1.0.M5.jar:1.1.0.M5] at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:640) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:343) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE] at ...
The discovery service is Consul.
Thanks in advance!