0

I'm using SpringBoot with Intellij IDEA. I believe I have all the dependencies needed. Still I keep getting PostgreSQL driver not found error. Here are the dependencies in the Gradle File.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-jersey'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    runtimeOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
2
  • 1
    Which of those dependencies do you believe include the PostgreSQL JDBC driver, and why do you believe that? Or more specifically, why do you believe it includes the PostgreSQL driver, and not a driver for some other database? Commented Mar 3, 2019 at 8:48
  • I got this list from Spring.io starter kit. I thought that they must have included these basic pre-requisites in the JPA starter lib that I had. I 'm surprised that they didn't. Commented Mar 3, 2019 at 8:52

1 Answer 1

2

Add the following dependency also:

compile group: 'org.postgresql', name: 'postgresql', version: '42.1.1'

After inclusion of the dependency in the gradle.build file also include the following lines in your Application.properties file to inform the application where the PostgreSQL server is and what are the credentials to access the database

spring.datasource.url= jdbc:postgresql://localhost:5432/dbname
spring.datasource.username=postgres
spring.datasource.password=xxxxxxxx
spring.jpa.hibernate.ddl-auto=create-drop
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. This seems to have solved that problem, let me look into the problem with JDBC URL and then I should be good to do. Thanks again.
Gasbos May I know why we needed the last property and its value create-drop.
You can set spring.jpa.hibernate.ddl-auto explicitly and the standard Hibernate property values are none, validate, update, create, and create-drop. Spring Boot chooses a default value for you based on whether it thinks your database is embedded. It defaults to create-drop if no schema manager has been detected or none in all other cases. docs.spring.io/spring-boot/docs/current/reference/html/…
Thanks , let me check the documentation.
runtimeOnly dependency should be enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.