Skip to content

Installation ​

A CoApi application needs three things on the classpath:

  1. The CoApi starter.
  2. An HTTP client builder for the client mode: WebClient (reactive) or RestClient (sync).
  3. Optional extras: Spring Cloud LoadBalancer for serviceId/lb:// clients, and java-jwt for JWT token parsing.

Replace <version> (Maven: the coapi.version property) with the latest release (see version compatibility).

CoApi starter ​

kotlin
implementation("me.ahoo.coapi:coapi-spring-boot-starter:<version>")
groovy
implementation 'me.ahoo.coapi:coapi-spring-boot-starter:<version>'
xml
<dependency>
    <groupId>me.ahoo.coapi</groupId>
    <artifactId>coapi-spring-boot-starter</artifactId>
    <version>${coapi.version}</version>
</dependency>

To manage all CoApi artifacts with one version, import the BOM me.ahoo.coapi:coapi-bom and drop the versions:

kotlin
implementation(platform("me.ahoo.coapi:coapi-bom:<version>"))
implementation("me.ahoo.coapi:coapi-spring-boot-starter")
xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>me.ahoo.coapi</groupId>
            <artifactId>coapi-bom</artifactId>
            <version>${coapi.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

HTTP client builder ​

CoApi builds each client from the application's WebClient.Builder or RestClient.Builder bean. The CoApi starter does not bring these in. In Spring Boot 4 they come from dedicated starters:

Client modeAdd
Reactive (WebClient)org.springframework.boot:spring-boot-starter-webclient
Sync (RestClient)org.springframework.boot:spring-boot-starter-restclient

Without the matching builder, startup fails with NoSuchBeanDefinitionException for WebClient.Builder or RestClient.Builder.

AUTO mode follows the classpath

With the default coapi.mode=AUTO, CoApi uses WebClient whenever Spring WebFlux is on the classpath, even in a servlet application. If you need RestClient while WebFlux is present, set coapi.mode=SYNC. See Client Modes.

Optional extras ​

Load balancing (serviceId, lb://, @LoadBalanced) needs Spring Cloud LoadBalancer and the Spring Cloud BOM matching your Spring Boot version:

kotlin
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:<spring-cloud-version>"))
implementation("org.springframework.cloud:spring-cloud-starter-loadbalancer")

JWT expiry parsing (String.jwtToExpirableToken(), see Authentication) needs com.auth0:java-jwt:

kotlin
implementation("com.auth0:java-jwt:<java-jwt-version>")

Artifacts ​

ArtifactContentsUse it when
coapi-spring-boot-starterAuto-configuration and coapi.* propertiesSpring Boot applications (the usual case)
coapi-springRegistrars, factory beans, client SPI, auth filtersPlain Spring without Boot, using @EnableCoApi
coapi-api@CoApi and @LoadBalanced onlyAPI modules that declare clients but shouldn't depend on Spring Boot
coapi-bomVersion alignment for the artifacts aboveImporting versions once

The coapi-api split lets a provider publish a lightweight client module, like example-provider-api, that consumers pick up without inheriting Spring Boot.

Next step ​

Quick Start: define and call your first client.