DInject has moved to avaje.io/http - taking you there now ...


Create controllers with @Path and @Controller.


The javalin-generator (APT processor) detects classes with @Controller and generates source code for mapping web routes to the controller method.


@Path("/contacts") provides the path segment that is prepended to any path segments defined by @Get, @Post etc.

class ContactController {

  private final MyService myService;

  ContactController(MyService myService) {
    this.myService = myService;

  Contact getById(long id) {

  void save(Contact contact) {


The controllers can have dependencies injected.


One of the big motivations of having these controllers is to help with testing.

When testing the ContactController:

  • We can create ContactController instances with mock/test doubles for it's dependencies (MyService)
  • We can largely test the methods without any web context/request/response objects