im pretty new in working with dropwizard. Currently I\'m trying to implement the HK2 dependency injection. That works pretty fine inside a resource but it doesn\'t work outs
If you are going to instantiate the service yourself then it is not going to go through the DI lifecycle and will never be injected. You can let the container create the service if you just register the services as a class
bind(ContentModuleManager.class)
.to(ContentModuleManager.class)
.in(Singleton.class);
On the other hand, if you are creating all the services yourself and you have all of them available, why don't you just not use the DI container at all? Just pass all the services through the constructor. Whether you are using constructor injection1 or manually passing through the constructor, getting the service through the constructor is good practice anyway, as it allows for easier testing of the service.
1 - Constructor injection
private Service service;
@Inject
public OtherService(Service service) {
this.service = service;
}