Describe the bug

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

To Reproduce

It happens often, even though in my appilcation.properties file I have them both defined, although I shouldn't have to define the driver Spring should recognize it right just by the jdbc:mysql datasource?

JDBC Properties

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

Expected behavior It should load up from the application file, but sometimes it doesn't. I have to either rebuild the project, or do a re-start of Spring Boot STS 3.1.2 Even then sometimes it happens still. This is a multi-module project with a backend module and a front end as well as a common module to share libraries. I have the datasource defined in the backend module. Am I doing something wrong? Or is this an anomaly I just have to live with?

Sample

A link to a GitHub repository with a minimal, reproducible sample.

Reports that include a sample will take priority over reports that do not. At times, we may require a sample, so it is good to try and include a sample up front.

Comment From: flaviandiold

Hey @CyberRookie, it would be helpful if you could also mention if you are using Spring Data JPA or only using JDBC. And also in order to not have to rebuild the entire project for every change you do, try adding Spring dev-tools into your pom.xml file

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency>

This would be the dependency snippet you have to add under ...

In the case you are using JPAs, you should provide Spring with more application properties such as: spring.jpa.database= spring.jpa.hibernate.ddl-auto= spring.jpa.properties.hibernate.dialect=

Comment From: CyberRookie

Yes. Yes, And Yes. The dependencies are there on the Backend pom file I Tried moving them to the FrontEnd of the project and leave them out of the backend, but that was a total disaster too since the backend does all the database work, I'm just asking questions at this point since it seems to happen a lot.


From: Flavian Diol D @.> Sent: Saturday, August 19, 2023 1:08 AM To: spring-projects/spring-security @.> Cc: Mark Stevens @.>; Mention @.> Subject: Re: [spring-projects/spring-security] Failed to configure a DataSource (Issue #13706)

Hey @CyberRookiehttps://github.com/CyberRookie, it would be helpful if you could also mention if you are using Spring Data JPA or only using JDBC. And also in order to not have to rebuild the entire project for every change you do, try adding Spring dev-tools into your pom.xml file org.springframework.boot spring-boot-devtools runtime This would be the dependency snippet you have to add under ...

— Reply to this email directly, view it on GitHubhttps://github.com/spring-projects/spring-security/issues/13706#issuecomment-1684819973, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APLVTXKEJSO3J7AWDO7H47TXWBC3TANCNFSM6AAAAAA3WAIEFA. You are receiving this because you were mentioned.Message ID: @.***>

Comment From: FlavioRbs1

Hi, @CyberRookie , Today I had this issue. I fixed this, converting the application.properties file, in “.yaml” file, see this link. https://planet4tech.com/post/failed-to-configure-a-datasource-url-attribute-is-not-specified-and-no-embedded-datasource-could-be-configured I hope help you.

Comment From: jzheaux

Thanks for reaching out, @CyberRookie. This doesn't appear to relate to the Spring Security project, so I'm going to close the issue. Please consider posting an issue on StackOverflow with the appropriate Spring Boot tags so you can get your questions answered. If you feel like you've run into an bug or want to suggest a feature, please log an issue with the Spring Boot team.

Comment From: Pawankumar1108

Try to add @Entity on your Entity Class