Spring-boot: Failed to determine a suitable driver class

Created on 17 Jul 2018  ·  20Comments  ·  Source: spring-projects/spring-boot

Spring Boot Version: 2.0.3.RELEASE

application.properties

###--- Database   ---###
spring.datasource.url = jdbc:mysql://localhost:3306/mydb
spring.datasource.username = root
spring.datasource.password = password
spring.datasource.platform = mysql
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto = create
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

Pom.xml contains

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    ... 
        <!-- Database dependencies -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

When I run my application, I get following error

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-17 12:31:12.528 ERROR 15387 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

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


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

After searching for a bit, I found that if I use earlier versions like 1.5.13.RELEASE this doesn't happen.

Most helpful comment

Apologies for replying late, I was not able to isolate the issue but now I did and came here to give the solution.

My application organization looked like below
Commons | ↓ Module1
Commons was a parent to Module1.

I had created a BaseEntity having JPA annotations in my commons module. The commons dependency was specified as

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

Once I added the <scope>provided</scope>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <scope>provided</scope>
        </dependency>

The issue got resolved for me. Unfortunately, I'm not able to do further analysis nor I can share the code.

All 20 comments

Failure analysis doesn't match the bits of configuration you've shared. It's a bit unclear at this point where the problem can be. Rather than pasting code in text, please share a sample we can clone and run that reproduces the problem.

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Hello ,
I have the same issue using the version 2.0.0.RELEASE of spring boot using the configuration bellow :
spring: dao: exceptiontranslation: enabled: false datasource: url: jdbc:postgresql://localhost:35432/db?binaryTransferEnable=142 hikari: pool-name: junit-pool username: username password: password driver-class-name: org.postgresql.Driver

@MustaphaCh thank you for trying to help but that's not a sample we can clone and run ourselves. If you have one, we're more than happy to have a look.

@snicoll i attach the application.yml you could you check my configuration please ?
application.zip

@MustaphaCh thanks again but a configuration file is not a sample that we can run ourselves.

@snicoll sorry the problem is fixed it was related to a profile.

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Apologies for replying late, I was not able to isolate the issue but now I did and came here to give the solution.

My application organization looked like below
Commons | ↓ Module1
Commons was a parent to Module1.

I had created a BaseEntity having JPA annotations in my commons module. The commons dependency was specified as

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

Once I added the <scope>provided</scope>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <scope>provided</scope>
        </dependency>

The issue got resolved for me. Unfortunately, I'm not able to do further analysis nor I can share the code.

the same issue worked for me on the same release

Thank for the fix mate

make sure the mysql is started ,
and update the application,properties

This fix worked for me as well, good job @ghsatpute.However I would like to put my experience. My project was working perfectly with Eclipse. I didn't have any problem with it before I move the project to intellij. Going back to eclipse and removing your fix, works.

@Tsakirogf always happy to help.
For me, it did work on IntelliJ after the fix.

Yes as I said, it worked for me.What I wanted to spot is that without the fix it was working for Eclipse.

please can you explain where i can find the commons and module1 you identified in your explanation

@oselene Those are my projects and taken here as an example. For you, those modules would be different.

Hello,
I am facing the same issue with Spring boot 2.1.2 release

@premierDE that comment is not very helpful. If you need help, please consider asking a question on StackOverflow or join the community on Gitter. If you believe you've found a bug in Spring Boot, attach a minimal sample we can run ourselves and we can reopen this issue.

I got the same problem with spring-boot 2.1.3 RELEASE. I marked my project with <packaging>pom</packaging> (stupid) so It didn't work, removing this resolved my issue.

```
jar
war

```choose any of the above if you don't have any sub module in project.

Was this page helpful?
0 / 5 - 0 ratings