Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreSpring Cloud Consul provides http://consul.io[Consul] integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with Hashicorp's Consul. The patterns provided include Service Discovery, Distributed Configuration and Control Bus.
Spring Cloud Consul features:
As long as Spring Cloud Consul and the Consul API are on the
classpath any Spring Boot application with @EnableDiscoveryClient
will try to contact a Consul
agent on localhost:8500
(the default values of
spring.cloud.consul.host
and spring.cloud.consul.port
respectively):
@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@RestController
public class Application {
@RequestMapping("/")
public String home() {
return "Hello World";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
A local Consul agent must be running. See the https://consul.io/docs/agent/basics.html[Consul agent documentation] on how to run an agent.
Bootstrap your application with Spring Initializr.