Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 合并从<;加载的属性;util:properties>;属性定义自<;道具>;要素_Java_Spring_Hibernate - Fatal编程技术网

Java 合并从<;加载的属性;util:properties>;属性定义自<;道具>;要素

Java 合并从<;加载的属性;util:properties>;属性定义自<;道具>;要素,java,spring,hibernate,Java,Spring,Hibernate,我有一个hibernate.properties文件,它保存我的应用程序的所有hibernate属性。Hibernate SessionFactoryBean从my applicationContext.xml文件中引用此文件: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <pr

我有一个hibernate.properties文件,它保存我的应用程序的所有hibernate属性。Hibernate SessionFactoryBean从my applicationContext.xml文件中引用此文件:

<bean id="sessionFactory" 
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="annotatedClasses">
       ...
    </property>
    <property name="hibernateProperties">
        <util:properties location="classpath:hibernate.properties"/>
    </property>
    ...
</bean>

...
...
现在,我想将hibernate.dial属性移动到另一个文件中,以便将其与其他特定于数据库的(连接)参数保持在一起

我尝试将SessionFactorybean的部分更改为:

<property name="hibernateProperties">
    <util:properties location="classpath:hibernate.properties"/>
    <props>
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    </props>
</property>

${hibernate.dial}
但是,这是不受支持的。我还尝试在其周围包装一个元素,但这与预期的java.util.Properties类型不兼容

如何在引用属性文件的同时仍然直接在上下文文件中添加单个hibernate.dial属性

或者,如果我可以直接在hibernate.properties文件中引用单个属性也可以,但我目前的研究表明这是不受支持的。

您可以这样做:

<util:properties id="hibernateProperties" location="classpath:hibernate.properties">
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
</util:properties>

${hibernate.dial}
您可以执行以下操作:

<util:properties id="hibernateProperties" location="classpath:hibernate.properties">
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
</util:properties>

${hibernate.dial}