简体   繁体   中英

Spring 2.4.2 spring.hazelcast.config ignored?

I have added the JVM start the parameter:

-Dspring.hazelcast.config=classpath:hazelcast2.xml

but in log I see

08:54:59.849 [I] [main           ] AbstractConfigLocator.log:49 - Loading 'hazelcast.xml' from the classpath.

Inside the jar does exist this hazelcast2.xml I puttet also outside of the jar inside start folder these file.

Why he falls back to internal hazelcast.xml ?

I can put a changed hazlecast.xml outside the jar and this is respected. But how I can change the hazlecast.xml file name using JVM parameters like documented in https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.hazelcast

I put the parameter in application.properties without success.

spring boot 2.4.2 hazelcast 4.1.1

Could you try this one?

-Dhazelcast.client.config=classpath:hazelcast2.xml

the searched parameter is:

-Dhazelcast.config=classpath:hazelcast2.xml

reason is in com.hazelcast.internal.config.AbstractConfigLocator.locateEverywhere()

    public boolean locateEverywhere() {
        return locateFromSystemPropertyOrFailOnUnacceptedSuffix()
                || locateInWorkDir()
                || locateOnClasspath()
                || locateDefault();
    }
  • The issue here is, that locateOnClasspath and locateOnClasspath only search for hazelcast.xml and locateFromSystemPropertyOrFailOnUnacceptedSuffix is loading from a env variable with name defined in com.hazelcast.internal.config.DeclarativeConfigUtil.SYSPROP_MEMBER_CONFIG = "hazelcast.config";
  • I would see it as a bug. But maybe there was an intention to do it so.

I found also this docu: https://docs.hazelcast.com/imdg/4.2/configuration/configuring-declaratively.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM