A module to marry together JDBI bound resources to the Guice dependency injection framework.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.md
pom.xml
release.properties

README.md

Build Status codecov.io

jdbi-guice

A module to marry together JDBI bound resources to the Guice dependency injection framework.

Injector injector = Guice.createInjector(JdbiModule.builder().scan("com.github.mlk.guice.dao").build(),
                new AbstractModule() {
                    @Override
                    protected void configure() {
                        bind(DBI.class).toInstance(new DBI("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"));
                    }
                });
        MyDAO myDAO = injector.getInstance(MyDAO.class);

        myDAO.createSomethingTable();
        myDAO.insert(1, "fred");
        System.out.println(myDAO.findNameById(1));

It is on Maven, so use it with:

<dependency>
  <groupId>com.github.mlk</groupId>
  <artifactId>jdbi-guice</artifactId>
  <version>1.0.0</version>
</dependency>