簡體   English   中英

嘗試將C3P0與Hibernate一起使用

[英]Try to use C3P0 with Hibernate

我正在使用JPA並且具有以下配置的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd ">


    <persistence-unit name="odontonewPU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="false" />
<!--            <property name="hibernate.hbm2ddl.auto" value="update" /> -->

            <!--   C3P0 configuration -->
            <property name="hibernate.connection.provider_class"
                value="org.hibernate.connection.C3P0ConnectionProvider" />

            <property name="hibernate.c3p0.max_size" value="100" />
            <property name="hibernate.c3p0.min_size" value="0" />
            <property name="hibernate.c3p0.acquire_increment" value="1" />
            <property name="hibernate.c3p0.idle_test_period" value="300" />
            <property name="hibernate.c3p0.max_statements" value="0" />
            <property name="hibernate.c3p0.timeout" value="100" />
        </properties>
    </persistence-unit>

</persistence>

問題是,當我嘗試初始化我的tomcat時,我收到以下錯誤:

691 [Thread-2] ERROR org.hibernate.connection.ConnectionProviderFactory - Could not instantiate connection provider
java.lang.ClassNotFoundException: org.hibernate.connection.C3P0ConnectionProvider

在我的pom.xml(我使用maven)中,我有以下依賴項:

<dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

該類是hibernate-c3p0一部分。 您需要添加依賴項

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>4.2.7.Final</version>
</dependency>

或者您需要的任何版本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM