tuts fun
tuts fun

Reputation: 117

Failed to configure a DataSource: 'url' attribute is not specified using Spring Boot

this is a first time i am doing a simple spring boot crud i ran in to the problem with

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

i don't how to solve the problem I added in drivers correct way but I got the error pls solve this problem

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=

porm.xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

Upvotes: 0

Views: 303

Answers (2)

Ronij Pandey
Ronij Pandey

Reputation: 133

You can try adding driver class in application.properties

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

You can also add the following and modify as per your need

spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update

Upvotes: 0

Ankur
Ankur

Reputation: 922

It seems that you failed to provide driver-class name.

spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

You can refer to : https://www.baeldung.com/spring-boot-failed-to-configure-data-source

It should be work after adding the above mentioned properties.

Upvotes: 1

Related Questions