IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver, 都maven配置了 pgsql的jar包,为何还是报错

源码节点 发布于 10/05 23:06
阅读 220
收藏 0

华为云11月刊推送:DIY微信问答机器人,高性能计算代码的20个技巧!>>>

IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver, 都maven配置了 pgsql的jar包,为何还是报错: Cannot load driver class: com.postgresql.jdbc.Driver ,,,,, <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.16</version>
</dependency>

 

 

加载中
0
源码节点
源码节点

解决方案>

 

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

 


 

< dependency> 
< groupId> org.postgresql< / groupId> 
< artifactId> postgresql< / artifactId> 
< version> 9.3-1101-jdbc41< / version> 
< /依赖关系>
1
源码节点
源码节点

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    ... 138 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver
    at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224) ~[spring-boot-autoconfigure-2.1.4.RELEASE.jar:2.1.4.RELEASE]

0
源码节点
源码节点

    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:367) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    ... 112 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver

0
成功大侠
成功大侠

IllegalStateException: Cannot load driver class: com.postgresql.jdbc.Driver, 这个包是不是有wen't

返回顶部
顶部