[id='setting-up-spring-cache_{context}']
= Setting up Spring caching with {brandname}

Add the {brandname} dependencies to your Spring application project.
If you use remote caches in a {brandname} Server deployment, you should also configure your Hot Rod client properties.

[IMPORTANT]
====
{brandname} supports Spring version 5 and version 6.
Be aware that Spring 6 requires Java 17.

The examples in this document include artifacts for the latest version of Spring.
If you want to use Spring 5 use:

* Remote caches: `infinispan-spring5-remote`
* Embedded caches: `infinispan-spring5-embedded`
====

.Procedure
. Add {brandname} and the Spring integration module to your `pom.xml`.
+
* Remote caches: `infinispan-spring6-remote`
* Embedded caches: `infinispan-spring6-embedded`
+
[TIP]
====
Spring Boot users can add the following artifacts instead of the `infinispan-spring6-embedded`:

* For Spring Boot 3 add `infinispan-spring-boot3-starter-embedded`
* For Spring Boot 2.x add `infinispan-spring-boot-starter-embedded`
====
. Configure your Hot Rod client to connect to your {brandname} Server deployment in the `hotrod-client.properties` file.
+
[source,xml,options="nowrap",subs=attributes+]
----
include::properties/hotrod-client-remote.properties[]
----

[discrete]
== Spring Cache dependencies

.Remote caches
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::dependencies_maven/spring_cache_remote.xml[]
----

.Embedded caches
[source,xml,options="nowrap",subs=attributes+,role="secondary"]
----
include::dependencies_maven/spring_cache_embedded.xml[]
----

[role="_additional-resources"]
.Additional resources
* link:{hotrod_docs}#configuring-hotrod-java-clients_hotrod-client-configuration[Configuring Hot Rod Client connections]
