The Cloudant Java SDK has new support for Spring Framework and Spring Boot.
This repository contains a few projects to walk you through what this new support provides when working with Spring and Cloudant.
- greeting-springboot: The "Before" case. This Spring Boot application connects to a Cloudant database using only the Cloudant Java library
com.cloudant:cloudant-client
- greeting-spring-framework: This Spring Framework application uses the new
@EnableCloudant
annotation from thecom.cloudant:cloudant-spring-framework
library to connect to a Cloudant database - greeting-springboot-auto: This Spring Boot application uses the new
com.cloudant:cloudant-spring-boot-starter
library to automatically configure and connect to a Cloudant database - greeting-springboot-liberty: This Spring Boot application uses the autoconfiguration support for Cloudant, but also uses OpenLiberty in place of Tomcat.
The official Cloudant Java Client provides libraries for Java applications to connect to, and interact with Cloudant databases. The new Cloudant Spring Library builds on top of the Cloudant Java Client to enable autoconfiguration for Spring Boot applications and exposes an @EnableCloudant
annotation for Spring Framework applications.
Before the creation of the Cloudant Spring Library developers had to include configuration for Spring beans that connected to Cloudant in their application code. Now the beans are provided by the library.
Before:
- Cloudant Java client is provided by the library as a dependency in Maven Central
- Spring configuration classes are included in the application
After:
- Cloudant Spring library pulls in Cloudant Java client as a dependency
- Spring configuration classes are pulled in as a dependency in Maven Central
The new Cloudant Spring client provides both the beans used for connecting to Cloudant and the configuration properties file for specifying credential information. The library is pulled in as a dependency from Maven Central.
Before:
- Cloudant Java client is provided by the library as a dependency in Maven Central called
com.cloudant:cloudant-client
- Definition of Cloudant beans and properties are included in the application
After:
- Cloudant Spring library pulls in
com.cloudant:cloudant-client
as a dependency - Cloudant beans and properties are pulled in as a dependency in Maven Central called
com.cloudant:cloudant-spring-boot-starter
orcom.cloudant:cloudant-spring-framework