2

I'm trying to integrate my spring boot app (web services) with Sqlite database, but I'm stucked at the beginning. Due to documentation I had specified connection url:

spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:sqlite:test.db

And added dependency to apprpiate lib (with and without "scope runtime" result is the same):

<packaging>jar</packaging>

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

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

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

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

(repositories...)

While I try to run my app I see information in console:


APPLICATION FAILED TO START


Description:

Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

Property: driverclassname

Value: org.sqlite.JDBC

Origin: "driverClassName" from property source "source"

Reason: Unable to set value for property driver-class-name

Action:

Update your application's configuration

First thing what I had checked it's that lib with class org.sqlite.JDBC (sqlite-jdbc-3.21.0.1.jar) is in my uber-jar (I generated it with mvn clean install with skip-tests flag) and it exists (it's packaged in my_app.jar\BOOT-INF\lib). Even when I'm starting my app from commandline I see same error (so it's not sts error).

Next, I thinked that maybe I have to specify driver class name manually, so i wrote:

spring.datasource.driver-class-name=org.sqlite.JDBC

And then I see stacktrace:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.sqlite.JDBC
(...)

Next, I tried to add another starter:

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

... but nothing was changed

I have no other idea how to deal with this problem. I had googled for configuring spring-boot and sqlite, but I didn't found anything helpful.

Please help, I'll be very thankfull for any clue :)

PS: my app was working properly on MySql database

PS2: I'm using newest version of hibernate and I don't have problem with sql dialect

Community
  • 1
  • 1
Kuba Samczuk
  • 111
  • 6
  • Possible duplicate of [spring boot: configure Sqlite database](https://stackoverflow.com/questions/42890375/spring-boot-configure-sqlite-database) – sidgate May 03 '18 at 08:24
  • @sidgate , thanks for yuor response. I had seen earlier that question in provided link - my problem it's not duplicate it. I don't have problems with dialect – Kuba Samczuk May 03 '18 at 08:54

0 Answers0