2

I am trying to solve this problem in my project, but it appears every time. I have already added properties with prefix spring.datasource but it is still not working.

So can somebody help me?

I want to build web application with Spring Boot, MySQL and Hibernate. I have not found the answer in internet. Thanks.

2016-10-22 14:49:15.072 ERROR 23100 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the       classpath. If you have database settings to be loaded from a particular profile  you may need to active it (no profiles are currently active).

Here is my code:

<groupId>com</groupId>
<artifactId>lardi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Phone Book</name>

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <start-class>com.SpringBootWebApplication</start-class>

    <!-- JSON -->
    <jackson-json.version>2.8.0</jackson-json.version>

    <!-- WEB jars -->
    <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
    <webjars-jquery.version>2.2.4</webjars-jquery.version>
    <webjars-noty.version>2.3.8</webjars-noty.version>
    <webjars-datatables.version>1.10.12</webjars-datatables.version>
</properties>

<build>
    <plugins>
        <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
</parent>

<dependencies>
    <!-- Spring Boot WEB -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <!-- Spring Boot TEST -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- Spring Boot Validation -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <!-- Spring Boot Security -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <!-- Spring Boot JPA -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- MySQL -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <!-- JSON -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson-json.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-hibernate5</artifactId>
        <version>${jackson-json.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>${jackson-json.version}</version>
    </dependency>
    <!-- Webjars -->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>${webjars-bootstrap.version}</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>jquery</artifactId>
        <version>${webjars-jquery.version}</version>
    </dependency>
    <dependency>
        <groupId>org.webjars.bower</groupId>
        <artifactId>noty</artifactId>
        <version>${webjars-noty.version}</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>datatables</artifactId>
        <version>${webjars-datatables.version}</version>
    </dependency>
</dependencies>

@SpringBootApplication
@EnableJpaRepositories(basePackageClasses = {Contact.class, User.class, BaseEntity.class})
public class SpringBootWebApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootWebApplication.class, args);
    }
}

Here is my properties:

spring.jpa.database=MYSQL
spring.datasource.url=jdbc:mysql://localhost:3306/lardi
spring.datasource.username=root
spring.datasource.password=2940063
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
useSSL=false
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
7
  • and your properties? Commented Oct 22, 2016 at 12:27
  • sorry, i forget it. Here: Commented Oct 22, 2016 at 12:49
  • spring.jpa.database=MYSQL spring.datasource.url=jdbc:mysql://localhost:3306/lardi spring.datasource.username=root spring.datasource.password=2940063 spring.datasource.driver-class-name=com.mysql.jdbc.Driver useSSL=false spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=validate spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect Commented Oct 22, 2016 at 12:49
  • My guess is that it is not picking up your properties. Are these properties defined in application.properties located in src/main/resources? Commented Oct 22, 2016 at 13:47
  • I solved my question. The problem was in location application.properties. It was is src/main/resources.properties and should be simply in src/main/resources. Commented Oct 22, 2016 at 13:56

1 Answer 1

1

You need to tell Spring Boot how to connect to your database. If you've added the driver, we can't guess the location and authentication information for you. You will find more information in the documentation

Try to add the following in src/main/resources/application.properties

spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring.datasource.password=dbpass

Of course, you'll have to adapt the name of the database (test) and the username/password.

Sign up to request clarification or add additional context in comments.

1 Comment

No, it is still not working. I have the same exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.