Getting started with Spring and Hazelcast
This article is a getting-started tutorial on integrating Hazelcast into a Spring project.
Part 1: Create Spring project
If you have already created the Spring project, skip to Part 2.
- Create a maven project.
mvn archetype:generate -DgroupId=spring_hazelcast -DartifactId=spring_hazelcast - Add spring dependencies into pom.
https://gist.github.com/2308457 - Create a TestBean.
https://gist.github.com/2308466 - Create beans.xml in your source root (src/main/java/beans.xml)
https://gist.github.com/2308478 - Test your Spring app.
https://gist.github.com/2308514
If you see “success” printed, now we can integrate Hazelcast.
Part 2: Integrate Hazelcast
- Add Hazelcast dependencies
https://gist.github.com/2308541 - Add hz name spaces, Hazelcast configuration and an Hazelcast map bean to beans xml.
In hz:map definition, “id” is spring bean id, name refers to Hazelcast map’s name.
https://gist.github.com/2308666 - Test Hazelcast.
https://gist.github.com/2308679
You can download and browse the getting started project here:
https://github.com/enesakar/spring_hazelcast