[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 version 6 and version 7.
====

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

* For Spring Boot 3.x add `infinispan-spring-boot3-starter-embedded`
* For Spring Boot 4.x add `infinispan-spring-boot4-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 Spring 6
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::dependencies_maven/spring6_cache_remote.xml[]
----

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

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

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

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