Java 无法加载 JDBC 驱动程序类“com.postgresql.jdbc.Driver”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24460934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 12:20:09  来源:igfitidea点击:

Cannot load JDBC driver class 'com.postgresql.jdbc.Driver'

javahibernatepostgresqlmavenjdbc

提问by Charlie Harper

org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure HHH000342: Could not obtain connection to query metadata : Cannot load JDBC driver class 'com.postgresql.jdbc.Driver'

I'm getting this warning while starting my application, can you help me how to solve it? It's WARN, no error or exception. (it is in my maven,spring,hibernate application), i have exceptions when i want to access my database via hibernate, but i'm not sure if this is causing the problem, thanks.

我在启动应用程序时收到此警告,您能帮我解决吗?这是警告,没有错误或异常。(它在我的 maven、spring、hibernate 应用程序中),当我想通过 hibernate 访问我的数据库时有例外,但我不确定这是否导致了问题,谢谢。

回答by Kevin Bowersox

Add the dependency on the postgresql driver to your pom.xmlfile

将对 postgresql 驱动程序的依赖添加到您的pom.xml文件中

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.3-1101-jdbc41</version>
</dependency>