带有postgresql驱动程序的IllegalStateException



我的application.properties中有这个:

spring.datasource.initialize=true
spring.datasource.url=jdbc:postgresql://1.2.3.4:5432/myapp?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&sslmode=require
spring.datasource.username=account
spring.datasource.password=password
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.tomcat.initial-size=10
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.max-idle=100
spring.datasource.tomcat.max-active=100

当我声明运行我的应用程序时,它无法启动:

工厂方法"dataSource"引发异常;嵌套异常为java.lang.IllegalStateException:无法加载驱动程序类:org.postgresql.driver

我尝试向IntelliJ中的依赖项添加一个本地postgresql-jar,但这没有什么区别。我还在pom.xml中包含了spring-boot-starter-jdbc。如何解决此问题?

您添加的依赖项是什么?如果你使用的是spring-boot-parent及其依赖关系,那么包含这个就足够了

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>

添加依赖项时,您是否也刷新了intellij中的项目(maven或gradle或您使用的是什么(?

最新更新