在属性文件中存储树缓存集群属性
我正在使用 Jboss 4、hibenate、spring 和 treecache。由于我们有不同的环境,我想将集群信息存储在单独的属性文件中,并引用 treecache xml 文件中的内容。我将 treecache-optimistic.xml
复制到
\jboss-4.2.0.GA\server\Pearl\conf
\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>
我尝试过在 treecache-optimistic.xml 中引用它,如下所示:
<attribute name="ClusterName">${cluster.name}</attribute>
启动实例后,我通过 JMX 发现集群的名称是 ${cluster.name}
而不是属性的值 (<代码>集群名称)。我认为它无法以某种方式找到该属性,但如果我更改引用,
<attribute name="ClusterName">${cluster.name:DefaultValue}</attribute>
则会出现以下错误:
异常启动过滤器
ServletRequestScopeFilter
org.springframework.beans.factory.BeanCreationException
:创建类路径资源 [hibernate-spring.xml
中定义的名为“pearlSessionFactory
”的 bean 时出错]: 调用init
方法失败;嵌套异常为org.hibernate.cache.CacheException
:javax.management.MalformedObjectNameException
:属性值部分中的字符“:”无效
hibernate属性由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不知道为什么 treecache-optimistic.xml
无法处理属性文件:-(
谢谢 佐尔坦
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.2.0.GA\server\Pearl\conf
and setup the properties in \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:
<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
<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
The hibernate properties are configured by 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 :-(
Thanks
Zoltan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论