Hibernate:忽略C3P0属性

7

我收到了以下警告:

15:41:51,043 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-1) HHH000022: c3p0 properties were encountered, but the org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider provider class was not found on the classpath; these properties are going to be ignored.

以下是我在Hibernate.xfg.xml中设置的属性:

<property name="hibernate.c3p0.min_size">50</property>
<property name="hibernate.c3p0.max_size">200</property>
... (and other properties)

除上述属性外,我没有其他关于C3P0的配置。

这是我在Maven的pom.xml中配置的所有Hibernate和C3P0依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.4.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.3.1.Final</version>
</dependency>

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

我需要怎么做才能读取当前被忽略的属性?
1个回答

12
根据这篇帖子,看起来您缺少hibernate-c3p0依赖项。
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-c3p0</artifactId>
  <version>4.1.10.Final</version>
</dependency>

你需要将版本号与hibernate-core使用的版本匹配。


在这种情况下,可以查看这个答案 - Reimeus
好的,我按照说明添加了提供程序类,但现在出现如下错误:Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider。 - user1883212
该类位于由上述依赖项提供的hibernate-c3p0.jar中。请确保它在您的类路径上。 - Reimeus
1
如果我使用hibernate-c3p0 4.1.10.Final,它可以工作,但如果我使用4.3.0.final,则无法工作。在第二种情况下找不到该类。 - user1883212

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接