繁体   English   中英

无法从配置 XML 中的 porperties 文件中读取值

[英]Unable to read values from porperties file in config XML

我已经在类路径中放置了 hazelcast.properties 和 hazelcast config.xml 文件。 这是我的目录结构:

resources
|_
| spring-env
| |_
|   dev.properties
|_
  applicationContext-hazelcast.xml

在我的 applicationContext-hazelcast.xml 中:

<context:property-placeholder file-encoding="UTF-8" location="classpath:spring-env/dev.properties" /> 
<hz:hazelcast id="instance">
    <hz:config>
        <hz:instance-name>hz_instance</hz:instance-name>
        <hz:group name="dev" password="password"/>
        <hz:network port="${hazelcast.port}" port-auto-increment="false">
            <hz:join>
                <hz:multicast enabled="false"/>
                <hz:tcp-ip enabled="true">
                    <hz:members>${hazelcast.members}</hz:members>
                </hz:tcp-ip>
            </hz:join>              
        </hz:network>

一切正常,但是当服务器启动时,日志中会出现以下内容:

INFO: Configuring Hazelcast from 'file:/E:/.../MyApp/WEB-INF/classes/applicationContext-hazelcast.xml'.
Sep 16, 2016 3:15:47 PM com.hazelcast.config.AbstractConfigBuilder
WARNING: Could not find a value for property  'hazelcast.port' on node: port
Sep 16, 2016 3:15:47 PM com.hazelcast.config.AbstractConfigBuilder
WARNING: Could not find a value for property  'hazelcast.members' on node: null

尽管我在 dev.properties 文件中指定了这些属性:

#hazelcast properties
hazelcast.port = 35701
hazelcast.members = 127.0.0.1

知道为什么它无法从 dev.properties 文件中找到 ${hazelcast.port} 和 ${hazelcast.member} 属性的值吗?

注意:我对休眠二级缓存和我手动配置的缓存映射使用相同的配置文件。

如果您在系统属性中定义属性,即hazelcast.porthazelcast.members ,它将起作用。

HazelcastCacheRegionFactory启动并设置到System.property之前,从您的dev.properties 中读取这些属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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