To use Spring Boot for Apache Geode, simply declare the spring-geode-starter
on your Spring Boot application
classpath:
Maven.
<dependencies> <dependency> <groupId>org.springframework.geode</groupId> <artifactId>spring-geode-starter</artifactId> <version>1.2.13.RELEASE</version> </dependency> </dependencies
Gradle.
dependencies {
compile 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE'
}
![]() | Tip |
---|---|
To use VMware Tanzu GemFire in place of Apache Geode, simply change the |
If you anticipate using more than 1 Spring Boot for Apache Geode (SBDG) module in your Spring Boot application,
then you can also use the new org.springframework.geode:spring-geode-bom
Maven BOM in your application Maven POM.
Your application use case(s) may require more than 1 module if, for example, you need (HTTP) Session state management
and replication (e.g. spring-geode-starter-session
), or you need to enable Spring Boot Actuator endpoints for
Apache Geode (e.g. spring-geode-starter-actuator
), or perhaps you need assistance writing complex Unit
and (distributed) Integration Tests using Spring Test for Apache Geode (STDG) (e.g. spring-geode-starter-test
).
You can declare (include) and use any 1 of the SBDG modules:
spring-geode-starter
spring-geode-starter-actuator
spring-geode-starter-logging
spring-geode-starter-session
spring-geode-starter-test
When more than 1 SBDG module is in play, then it makes sense to use the spring-geode-bom
to manage all
the dependencies so that the versions and transitive dependencies necessarily align properly.
Your Spring Boot application Maven POM using the spring-geode-bom
along with 2 or more module dependencies
might appear as follows:
Spring Boot application Maven POM.
<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.13.RELEASE</version> </parent> <artifactId>my-spring-boot-application</artifactId> <properties> <spring-geode.version>1.2.13.RELEASE</spring-geode.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.geode</groupId> <artifactId>spring-geode-bom</artifactId> <version>${spring-geode.version}</version> <scope>import</scope> <type>pom</type> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.geode</groupId> <artifactId>spring-geode-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.geode</groupId> <artifactId>spring-geode-starter-session</artifactId> </dependency> <dependency> <groupId>org.springframework.geode</groupId> <artifactId>spring-geode-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> </project>
Notice that 1) the Spring Boot application Maven POM (pom.xml
) contains a <dependencyManagement>
section declaring
the org.springframework.geode:spring-geode-bom
and that 2) none of the spring-geode-starter[-xyz]
dependencies
explicitly specify a <version>
, which is 3) managed by the spring-geode.version
property making it easy to switch
between versions of SBDG as needed, applied evenly to all the SBDG modules declared and used in your application Maven
POM.
If you change the version of SBDG, make sure to change the org.springframework.boot:spring-boot-starter-parent
POM
version to match. SBDG is always 1 major
version behind, but matches on minor
version and patch
version
(and version qualifier
, e.g. SNAPSHOT
, M#
, RC#
, or RELEASE
, if applicable).
For example, SBDG 1.4.0
is based on Spring Boot 2.4.0
. SBDG 1.3.5.RELEASE
is based on
Spring Boot 2.3.5.RELEASE
and so on. It is important that the versions align.
Of course, all of these concerns are easy to do and handled for you by simply going to start.spring.io and adding the "Spring for Apache Geode" dependency.
Clink on this link to get started!
The user experience when using Gradle is similar to that of Maven.
Again, if you will be declaring and using more than 1 SBDG module in your Spring Boot application, for example,
the spring-geode-starter
along with the spring-geode-starter-actuator
dependency, then using the spring-geode-bom
inside your application Gradle build file will help.
Your application Gradle build file configuration will roughly appear as follows:
Spring Boot application Gradle build file.
plugins { id 'org.springframework.boot' version '2.2.13.RELEASE' id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'java' } // ... ext { set('springGeodeVersion', "1.2.13.RELEASE") } dependencies { implementation 'org.springframework.geode:spring-geode-starter' implementation 'org.springframework.geode:spring-geode-starter-actuator' testImplementation 'org.springframework.boot:spring-boot-starter-test' } dependencyManagement { imports { mavenBom "org.springframework.geode:spring-geode-bom:${springGeodeVersion}" } }
A combination of the Spring Boot Gradle Plugin and the Spring Dependency Management Gradle Plugin manage the application dependencies for you.
In a nutshell, the Spring Dependency Management Gradle Plugin provides dependency management capabilities for Gradle much like Maven. The Spring Boot Gradle Plugin defines a curated and tested set of versions for many 3rd party Java libraries. Together they make adding dependencies and managing (compatible) versions easier!
Again, you don’t need to explicitly declare the version when adding a dependency, including a new SBDG module dependency
(e.g. spring-geode-starter-session
) since this has already been determined for you. You can simply declare the
dependency:
implementation 'org.springframework.geode:spring-geode-starter-session'
The version of SBDG is controlled by the extension property (springGeodeVersion
) in the application Gradle build file.
To use a different version of SBDG, simply set the springGeodeVersion
property to the desired version
(e.g. 1.3.5.RELEASE
). Of course, make sure the version of Spring Boot matches!
SBDG is always 1 major
version behind, but matches on minor
version and patch
version (and version qualifier
,
e.g. SNAPSHOT
, M#
, RC#
, or RELEASE
, if applicable). For example, SBDG 1.4.0
is based on Spring Boot 2.4.0
.
SBDG 1.3.5.RELEASE
is based on Spring Boot 2.3.5.RELEASE
and so on. It is important that the versions align.
Of course, all of these concerns are easy to do and handled for you by simply going to start.spring.io and adding the "Spring for Apache Geode" dependency.
Clink on this link to get started!