JDBI Spring Boot Starter

This is a Spring Boot Starter for auto creating Jdbi and SqlObject

License

License

Categories

Categories

Spring Boot Container Microservices JDBI Data Databases
GroupId

GroupId

ca.pjer
ArtifactId

ArtifactId

jdbi-spring-boot-starter
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

JDBI Spring Boot Starter
This is a Spring Boot Starter for auto creating Jdbi and SqlObject
Project URL

Project URL

https://github.com/pierredavidbelanger/jdbi-spring-boot-starter
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/pierredavidbelanger/jdbi-spring-boot-starter

Download jdbi-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/ca.pjer/jdbi-spring-boot-starter/ -->
<dependency>
    <groupId>ca.pjer</groupId>
    <artifactId>jdbi-spring-boot-starter</artifactId>
    <version>1.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/ca.pjer/jdbi-spring-boot-starter/
implementation 'ca.pjer:jdbi-spring-boot-starter:1.3.0'
// https://jarcasting.com/artifacts/ca.pjer/jdbi-spring-boot-starter/
implementation ("ca.pjer:jdbi-spring-boot-starter:1.3.0")
'ca.pjer:jdbi-spring-boot-starter:jar:1.3.0'
<dependency org="ca.pjer" name="jdbi-spring-boot-starter" rev="1.3.0">
  <artifact name="jdbi-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='ca.pjer', module='jdbi-spring-boot-starter', version='1.3.0')
)
libraryDependencies += "ca.pjer" % "jdbi-spring-boot-starter" % "1.3.0"
[ca.pjer/jdbi-spring-boot-starter "1.3.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-jdbc jar 2.0.4.RELEASE
org.jdbi : jdbi3-core jar 3.4.0
org.jdbi : jdbi3-sqlobject jar 3.4.0

Project Modules

There are no modules declared in this project.

jdbi-spring-boot-starter

This is a Spring Boot Starter for auto creating Jdbi and SqlObject

Usage

Here you can find a working sample app.

Add this to your Spring Boot project's pom.xml:

<dependency>
    <groupId>ca.pjer</groupId>
    <artifactId>jdbi-spring-boot-starter</artifactId>
    <version>1.3.0</version>
</dependency>

Then after configuring a data source, you will be able to inject Jdbi like this:

import org.jdbi.v3.core.Jdbi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
class MyService {
    @Autowired Jdbi jdbi;
}

Now if you want to auto create and inject your SQL Objects into other components:

Annotate your main class with @EnableAutoSqlObject:

import ca.pjer.spring.boot.jdbi.EnableAutoSqlObject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAutoSqlObject
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

Also, annotate your SQL Objects (those you want auto created and injected) with @AutoSqlObject:

import ca.pjer.spring.boot.jdbi.AutoSqlObject;
import org.jdbi.v3.sqlobject.statement.SqlQuery;

@AutoSqlObject
public interface MyDAO {
    @SqlQuery("SELECT * FROM my_table")
    List<MyTable> findAll();
}

Then you will now be able to inject them like this:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
class MyService {
    @Autowired MyDAO myDAO;
}

Versions

Version
1.3.0
1.2.0
1.1.0
1.0.0
0.2.0
0.1.0