Skip to content

How to inject an instance in my controller from a normal guice module ? #1342

Description

@mbayealioune

Hi all,
I am using jooby 1.6.2
I want to do a field or constructor injection in my jooby controller from a standard guice module
I have an error like this:

  1. No implementation for mq.interfaces.AInt was bound.
    while locating mq.interfaces.AInt
    for field at controllers.B.mymethod(B.java:36)
    at org.jooby.Jooby.lambda$bindService$47(Jooby.java:3109)
    1 error
    at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:543) ~[guice-4.2.2.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:159) ~[guice-4.2.2.jar:na]
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) ~[guice-4.2.2.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:87) ~[guice-4.2.2.jar:na]
    at com.google.inject.Guice.createInjector(Guice.java:78) ~[guice-4.2.2.jar:na]
    at org.jooby.Jooby.lambda$new$0(Jooby.java:885) ~[jooby-1.6.2.jar:1.6.2]
    at org.jooby.Jooby.bootstrap(Jooby.java:2996) ~[jooby-1.6.2.jar:1.6.2]
    at org.jooby.Jooby.start(Jooby.java:2197) ~[jooby-1.6.2.jar:1.6.2]
    at org.jooby.Jooby.start(Jooby.java:2178) ~[jooby-1.6.2.jar:1.6.2]
    at org.jooby.Jooby.run(Jooby.java:2107) ~[jooby-1.6.2.jar:1.6.2]
    at app.MApplication.launch(MApplication.java:180) ~[classes/:na]

In my guice module I have:

bind(AInt.class).to(A.class);

In my jooby controller I have:

@javax.inject.Inject
private AInt varA;

Is that possible ?
How to do that using my guice standard modules only ?

Thank you in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions