Linux 在属性文件中存储 treecache 集群属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3677154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Storing treecache cluster properties in property file
提问by HamoriZ
I'm using Jboss 4, hibenate, spring and treecache. As we have different environments, I would like to store the cluster information in a separated property file and reference to the content from the treecache xml file. I copied the treecache-optimistic.xml
into
我正在使用 Jboss 4、hibenate、spring 和 treecache。由于我们有不同的环境,我想将集群信息存储在一个单独的属性文件中,并引用 treecache xml 文件中的内容。我复制treecache-optimistic.xml
到
\jboss-4.2.0.GA\server\Pearl\conf
and setup the properties in \jboss-4.2.0.GA\server\Pearl\deploy\properties-service.xml
并设置属性 \jboss-4.2.0.GA\server\Pearl\deploy\properties-service.xml
<attribute name="Properties">
cluster.name=CluterName
cluster.ip=228.1.3.1
cluster.port=48866
</attribute>
I tried to reference it in the treecache-optimistic.xml like this:
我尝试在 treecache-optimistic.xml 中引用它,如下所示:
<attribute name="ClusterName">${cluster.name}</attribute>
After starting the instance I found via JMX that the name of the cluster is ${cluster.name}
and not the value of the property (ClusterName
). I thought that it can not find the property somehow, but if I change the reference to
启动实例后,我通过 JMX 发现集群的名称是${cluster.name}
而不是属性 ( ClusterName
)的值。我认为它无法以某种方式找到该属性,但是如果我将引用更改为
<attribute name="ClusterName">${cluster.name:DefaultValue}</attribute>
then I get the following error:
然后我收到以下错误:
Exception starting filter
ServletRequestScopeFilter
org.springframework.beans.factory.BeanCreationException
: Error creating bean with name 'pearlSessionFactory
' defined in class path resource [hibernate-spring.xml
]: Invocation ofinit
method failed; nested exception isorg.hibernate.cache.CacheException
:javax.management.MalformedObjectNameException
: Invalid character ':' in value part of property
异常启动过滤器
ServletRequestScopeFilter
org.springframework.beans.factory.BeanCreationException
:pearlSessionFactory
在类路径资源 [hibernate-spring.xml
] 中定义名称为“ ”的bean 创建时出错:init
方法调用失败;嵌套异常是org.hibernate.cache.CacheException
:javax.management.MalformedObjectNameException
: 属性值部分中的无效字符“:”
The hibernate properties are configured by spring:
休眠属性由 spring 配置:
<!-- Database Property -->
<bean id="hibernatePropertiesPearl"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.TreeCacheProvider</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.max_fetch_depth">0</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
I do not know why the treecache-optimistic.xml
can not handle property files :-(
我不知道为什么treecache-optimistic.xml
不能处理属性文件:-(
Thanks Zoltan
谢谢佐尔坦