Search code examples
spring-bootderby

Configuration issue with apache derby in spring boot


In my spring boot based application, I have following in my pom.xml:

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

<dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <scope>runtime</scope>
</dependency>

When I start the application, I get following error:


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

As dependency is there in pom, so classpath must have already it. So what can be the issue here?

Edit: I have not added any configuration related to apache derby in application.properties. I understand we don't need to do it for embedded databases. Or do we need?


Solution

  • derby is expecting some datasource params like url for starting embedded server.

    Try including jpa/hibernate config details in application.properties

    Example:

    # Show or not log for each sql query
    spring.jpa.show-sql=true
    # Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
    # schema will be automatically created afresh for every start of application
    spring.jpa.hibernate.ddl-auto=create-drop
    # Allows Hibernate to generate SQL optimized for a particular DBMS
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyDialect