spring-boot: Failed to determine a suitable driver class

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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (4 by maintainers)

Most upvoted comments

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.

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.

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.

the same issue worked for me on the same release

Thank for the fix mate