close

Spring Cloud Consul

3.1.1

Spring Cloud Consul provides 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.

Features

Spring Cloud Consul features:

  • Service Discovery: instances can be registered with the Consul agent and clients can discover the instances using Spring-managed beans

  • Supports Ribbon, the client side load-balancer via Spring Cloud Netflix

  • Supports Spring Cloud LoadBalancer - a client side load-balancer provided by the Spring Cloud project

  • Supports Zuul, a dynamic router and filter via Spring Cloud Netflix

  • Distributed Configuration: using the Consul Key/Value store

  • Control Bus: Distributed control events using Consul Events

Quick Start

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 Consul agent documentation on how to run an agent.

Spring Initializr

Quickstart Your Project

Bootstrap your application with Spring Initializr.

Documentation

Each Spring project has its own; it explains in great details how you can use project features and what you can achieve with them.
3.1.1 CURRENT GA Reference Doc.
4.0.0-M3 PRE Reference Doc.
3.1.2-SNAPSHOT SNAPSHOT Reference Doc. API Doc.
3.0.5-SNAPSHOT SNAPSHOT Reference Doc.
3.0.4 GA Reference Doc.
2.2.8.BUILD-SNAPSHOT SNAPSHOT Reference Doc.
2.2.7.RELEASE GA Reference Doc.
Branch Initial Release End of Support End Commercial Support *
3.1.x
2021-11-30 2023-05-18 2024-08-22
3.0.x
2020-12-21 2022-05-19 2023-09-19
2.2.x
2019-11-26 2020-11-26 2022-03-26

OSS support

Free security updates and bugfixes with support from the Spring community. See VMware Tanzu OSS support policy.

Commercial support

Business support from Spring experts during the OSS timeline, plus extended support after OSS End-Of-Life.
Publicly available releases for critical bugfixes and security issues when requested by customers.

Future release

Generation not yet released, timeline is subject to changes.

About commercial support (*)

This page shows the current state of project releases and does not define the commercial support policy. Please refer to the official support policy for more information.

A few examples to try out: