This is a prerelease version.

View latest

Integrate with Spring

Spring is a popular framework for writing enterprise-grade Java applications. The Spring Framework includes a range of libraries to reduce the need for boilerplate code and encourages a consistent structure for ease of maintenance. Spring Boot further simplifies development by automatically configuring applications on your classpath.

Hazelcast Platform is integrated with the Spring Framework and Spring Boot, allowing you to easily incorporate Hazelcast’s fast data cache capabilities into your Spring applications.

Why use Hazelcast with Spring?

You can use Hazelcast to enhance your Spring applications with caching and session replication.

  • Cache: you can use Hazelcast as a Spring cache manager or a JCache-compliant cache, as described in the Spring Boot documentation.

  • Hibernate second-level cache: you can use Hazelcast as a second-level cache in your Hibernate LocalSessionFactoryBean configuration.

  • Session replication: you can use Hazelcast to replicate session data across multiple web applications or microservices. Hazelcast provides plugins for several web servers, including Spring’s default web server, Tomcat.

Using Spring also makes it easier to work with Hazelcast. You can:

  • Autowire Hazelcast objects, such as the distributed map (IMap), without needing to configure a Hazelcast member first. Spring Boot automatically configures a Hazelcast member if Hazelcast is on the classpath.

  • Use @SpringAware annotation on Hazelcast objects to enable dependency injection inside classes processed by Hazelcast, such as EntryProcessor and Callable.

  • Reduce the configuration needed to set up Hazelcast.

Architecture options

You can embed Hazelcast members in the same Java process as your Spring application or deploy them separately in a client/server topology. See Choosing an Application Topology.

Supported versions

Hazelcast supports the following Spring Framework versions:

  • Supported: 5.3.39+

  • Latest tested: 6.2.0