Dropwizard with Spring Framework support for DI
Java Shell Groovy
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.
gradle/wrapper
src
.gitignore
README.md
build.gradle
gradlew
gradlew.bat

README.md

Spring Framework support for Dropwizard

Dropwizard with Spring Framework support for DI

Motivation

We love Dropwizard and Spring framework. Unfortunately the existing solutions to bring together both technologies are outdated. We like Dropwizard latest version (yeah, the 0.7.0-SNAPSHOT).

And we love pragmatic programming models. The less we write, the more happiness we have. That's the reason this project was born.

Build Status

Build Status

Setup

Maven Setup

Very soon kids...

Gradle Setup

  1. Add the following both repos in your build.gradle file

    repositories {
      maven {
        url 'http://oss.sonatype.org/content/repositories/snapshots'
      }
      maven {
        url 'http://repo.sindica.to/nexus/content/repositories/public-milestones/'
      }
    }
  2. Add the following dependency

    dependencies {
      compile 'sindica.to:dropwizard-spring:0.3.0-SNAPSHOT'
    }

Development

  1. Create your Dropwizard Application extending from sindica.to.dropwizard.spring.SpringApplication

    package sindica.to.sample;
    
    import sindica.to.dropwizard.spring.SpringApplication;
    
    public class MyApp extends SpringApplication<MyConf> {
      public static void main(String[] args) throws Exception {
        new MyApp().run(args);
      }
    
      @Override
      public void onConfigureSpringContext(AnnotationConfigWebApplicationContext applicationContext) {
        //Scan your own packages for Spring beans with annotations
        //like @Component, @Repository, @Inject, @Autowired, etc
        applicationContext.scan("sindica.to.sample");
      }
    }
  2. Create the usual Dropwizard artifacts as always

    package sindica.to.sample.resource;
    
    import org.springframework.stereotype.Component;
    import sindica.to.sample.model.Person;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import java.util.List;
    
    @Path("/person")
    @Component
    public class PersonResource {
      @GET
      public List<Person> list() {
        //TODO: implement this...
      }
    }

    The trick is to add the Spring's Annotations like @Component

  3. Enjoy, hack, deliver, profit¡