Skip to content
Advertisement

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>

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement