0

I am trying to configure Spring boot and JPA in my application. After searching the Internet, I have configured my app like below (adding only relevant portion of code):

pom.xml:

        <!-- JPA Starter -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>${version.spring.boot}</version>
        </dependency>
        <!-- MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${version.mysql.driver}</version>
        </dependency>

application.properties:

spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

Application configuration Java class:

@StatelessBusinessService
@SpringBootApplication(
    scanBasePackages = { "com.org.ist.module.service" }
)
@EnableScheduling
public class MyServiceApplication extends SpringBootServletInitializer {
    public static void main(final String... args) {
        final SpringApplication app = new SpringApplication(MyServiceApplication.class);
        app.run(args);
    }

    @Override
    protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
        return builder.sources(MyServiceApplication.class);
    }

And below is the error which I get when I execute mvn spring-boot:run from terminal:

***************************
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).

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Maybe I have missed some simple configuration?

1
  • Does your project have a hibernate.properties or persistence.xml file? Commented Jul 31, 2017 at 3:00

1 Answer 1

1

Please try adding the below annotation to spring boot application class to exclude auto configuration of data source.

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks Anil :) I knew, I missed some simple config! May be you want to explain a bit about why one needs to exclude DataSourceAutoConfiguration.class though?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.