Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Hazelcast via Spring Boot application.yml

I was able to get Hazelcast caching working in my Spring Boot application with a hazelcast.xml file. However, the application has multiple profiles and I'm trying to avoid managing multiple hazelcast.xml files. I want to configure all of the options within the application.yml. If I understand the documentation correctly, I should be able to do the following in my application.yml, correct?

hazelcast:
  client:
    config:
      network:
        join:
          tcp-ip:
            member:
              - 1.2.3.4
              - 9.8.7.6
      map:
        name: user-details
        max-size: 1000
        eviction-policy: LRU
        eviction-percentage: 10
        time-to-live-seconds: 900

Except it's not working. I've tried finding other references to configuring Hazelcast through the application.yml but have found none. Is what I'm trying to do impossible?

like image 533
Derek Avatar asked Oct 22 '25 05:10

Derek


1 Answers

I faced the same issue and added a configuration class for this:

@Configuration
@EnableConfigurationProperties(HazelcastConfig::class)
@ConfigurationProperties(prefix = "hazelcast", ignoreUnknownFields = false)
@Primary
class HazelcastConfig: Config()

And then I just put this in the application.yml:

hazelcast:
  group_config:
    name: hazelcast-cluster
    password: hazelcast-cluster
  network_config:
    join:
      multicast_config:
        enabled: false
      kubernetes_config:
        enabled: false

(Yes I know it is an old question but it is the most popular according to Google)

like image 133
Milo van der Zee Avatar answered Oct 23 '25 18:10

Milo van der Zee