DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Working With Spring Boot and Hazelcast (Distributed Cache)
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Java, Spring Boot, and MongoDB: Performance Analysis and Improvements
  • How To Build Web Service Using Spring Boot 2.x

Trending

  • How To Verify Database Connection From a Spring Boot Application
  • Exploring Sorting Algorithms: A Comprehensive Guide
  • Building AI Applications With Java and Gradle
  • Memory Management in Java: An Introduction
  1. DZone
  2. Coding
  3. Frameworks
  4. Running and Testing Hazelcast in a Spring Boot Application

Running and Testing Hazelcast in a Spring Boot Application

How to start a Hazelcast instance in a Spring Boot application.

Peter Veentjer user avatar by
Peter Veentjer
·
Dec. 08, 15 · Tutorial
Like (2)
Save
Tweet
Share
13.63K Views

Join the DZone community and get the full member experience.

Join For Free

The folks over at OpenCredo recently published a blog post entitled, "Running and Testing Hazelcast in a Spring Boot Application." In the post, they introduce some of the basic features of Hazelcast, some of its limitations, how to embed it in a Spring Boot application and write integration testings. Here's how to start a Hazelcast instance in a Spring Boot application. 

Hazelcast in a Spring Boot Application

Starting a Hazelcast instance in a Spring Boot application is easy:

  1. Include the com.hazelcast:hazelcast dependency
  2. Initialise a com.hazelcast.config.Config Spring bean

The following example uses Spring Boot 1.3.0. This provides Hazelcast 3.5.3 as managed dependency.

pom.xml

…
<parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>1.3.0.RELEASE</version>
 <relativePath/>
</parent>
 …
<dependency>
 <groupId>com.hazelcast</groupId>
 <artifactId>hazelcast</artifactId>
 <!-- Version is managed by Spring Boot starter -->
</dependency>
…

Configuration

@Configuration
public class HazelcastConfiguration {
 @Bean
 public Config config() {
   return new Config(); // Set up any non-default config here
 }
}

Spring Boot automatically start a Hazelcast instance when it finds both:

  1. Hazelcast in classpath
  2. A com.hazelcast.config.Config bean.

On startup, an instance of com.hazelcast.core.HazelcastInstance is then added to the Spring Application Context.

Spring Framework Spring Boot application Hazelcast

Published at DZone with permission of Peter Veentjer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Working With Spring Boot and Hazelcast (Distributed Cache)
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Java, Spring Boot, and MongoDB: Performance Analysis and Improvements
  • How To Build Web Service Using Spring Boot 2.x

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: