在属性文件中存储树缓存集群属性

发布于 2024-09-18 09:34:22 字数 2057 浏览 5 评论 0原文

我正在使用 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.CacheExceptionjavax.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 of init method failed; nested exception is org.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文