java - 尝试使用 Spring WebFlow 在 Hibernate 中配置 c3p0 池

标签 java spring hibernate spring-webflow c3p0

我正在使用 Spring 在 Hibernate 中配置内置的 c3p0 池,但它给了我错误,它不喜欢任何 C3P0 东西,例如:

<prop name="hibernate.c3p0.min_size" value="2" />
<prop name="hibernate.c3p0.max_size" value="5" />

有人可以告诉我为什么吗?

<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <!--suppress InjectionValueTypeInspection -->
    <property name="mappingResources" ref="hibernateMappingList" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="transaction.factory_class">
                net.sf.hibernate.transaction.JDBCTransactionFactory
            </prop>
            <prop key="hibernate.transaction.factory_class">
                net.sf.hibernate.transaction.JDBCTransactionFactory
            </prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
            <prop key="hibernate.jdbc.batch_size">0</prop>

            <prop name="hibernate.c3p0.min_size" value="2" />
            <prop name="hibernate.c3p0.max_size" value="5" />
            <prop name="hibernate.c3p0.timeout" value="600" />
            <prop name="hibernate.c3p0.max_statements" value="0" />
            <prop name="hibernate.c3p0.idle_test_period" value="300"/>
            <prop name="hibernate.c3p0.acquire_increment" value="1" />
      </props>
    </property>
</bean>

这是我的数据库源信息:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">

        <!-- these are C3P0 properties -->
        <property name="acquireIncrement" value="${database.acquireIncrement}" />
        <property name="minPoolSize" value="${database.minPoolSize}" />
        <property name="maxPoolSize" value="${database.maxPoolSize}" /> 
        <property name="maxIdleTime" value="${database.maxIdleTime}" />

        <property name="driverClass" value="${database.driver}" />
        <property name="jdbcUrl" value="${database.url}" />
        <property name="user" value="${database.user}" />
        <property name="password" value="${database.password}" />
    </bean>

最佳答案

XML 错误。在下面的部分中

       <prop name="hibernate.c3p0.min_size" value="2" />
       <prop name="hibernate.c3p0.max_size" value="5" />
       <prop name="hibernate.c3p0.timeout" value="600" />
       <prop name="hibernate.c3p0.max_statements" value="0" />
       <prop name="hibernate.c3p0.idle_test_period" value="300"/>
       <prop name="hibernate.c3p0.acquire_increment" value="1" />

使用与其他属性相同的格式替换它

       <prop key="key">value</prop>

prop 元素使用与 property 元素不同的属性。

关于java - 尝试使用 Spring WebFlow 在 Hibernate 中配置 c3p0 池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12306004/

相关文章:

java - 层次继承的正确UML是什么?

java - 2秒后打印出语句

java - 实体管理器未持久保存在数据库中

java - Spring Security更改登录用户的角色不会立即生效

java - 持久化有序域对象

java - IntelliJ IDEA 2016 : Please choose persistence unit

java - Jackson - 有什么方法可以避免在运行时父实体的序列化吗?

java - 有没有办法使用 Perl 或 Java 将内容发布到 Drupal 站点?

java - 让 Spring/Jackson 智能地反序列化模型子类

java - JPA查询需要一些指导