-2

I am running my first Spring boot application with Postgresql database . I am getting the following error .

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

In application.properties I have

spring.datasource.url=jdbc.postgresql://localhost:5432/Education

What is that I am missing/need to consider?

user1907849
  • 960
  • 4
  • 19
  • 42

3 Answers3

2

You just need to add below dependency in your pom.xml.

As per error message, it's due to missing of postgreSQL drivers error.

It will load drivers for postgreSQL in your application.

        <!-- PostgreSQL -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>

Also try to add below entries in you application.yml or application.properties

spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/Education
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect

This will help you.

Sagar Gangwal
  • 7,544
  • 3
  • 24
  • 38
1

Check whether the postgres driver jar is part of your maven or gradle build.The missing jar might be causing this issue.

You can refer more to add the jar here: How to add postgres jar as dependency

1

Change this:

spring.datasource.url=jdbc.postgresql://localhost:5432/Education

to this:

spring.datasource.url=jdbc:postgresql://localhost:5432/Education

Does your application.properties file look like this?

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=admin
spring.datasource.initialization-mode=always
spring.datasource.initialize=true
spring.datasource.schema=classpath:/schema.sql
spring.datasource.continue-on-error=true

is postgres listening on localhost:5432 ?

Also, make sure you have these dependencies:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Alexandros Kourtis
  • 539
  • 2
  • 6
  • 20