I have the below mentioned class in a library module, which the clients will use to interact with database. I have a public constructor that takes a parameter from the user of this library, but the problem with this is that, its a Guice module getting instantiated inside this constructor. So when I try to wri…
Tag: guice
Expose Map from guice private Module
I am trying to expose a map from private module similar to Expose Map in private guice module but getting an error Could not expose() java.util.Map annotated with @com.google.inject.name.Named(value=myMap), it must be explicitly bound. I have written this code: Also in another class where I am injecting it, i…
traverse an array in GUI Java
I am doing a questionnaire with questions and written answers. I need that when adding the answer, press the main button, tell me if it is correct or not and show me the other question of the array, until the array is finished. Here I upload the whole code. Answer You have the right idea, but you need to proc…
Google Guice and Lombok – @AllArgsConstructor(onConstructor = @__(@Inject)) for abstract class
I find @AllArgsConstructor(onConstructor = @__(@Inject)) is helpful to keep code clean when working with Google Guice. I can save the constructor code. For example: For abstract class, I’m able to use @Inject for constructor. Is it possible to save the constructor code in ChildClass by using something l…
Guice -How to inject dependency inside the class which is extending Abstract module – Java
I have to trigger TestDriver.startPoller() from EnvironmentModule since EnvironmentModule is extending from Abstractmodule I am not sure how to inject dependency inside EnvironmentModule is it even …
Why am I getting “classes must have either one (and only one) constructor” error?
I have been trying to get Guice working but end up with this: Classes must have either one (and only one) constructor My interface: The implementation: The binding module: The AddrBook client where I am injecting: And my main: After all this, I’m getting this error: I have experience with Spring and not…
Guice: Injecting map binding with @Named
I would like to have the following injection model. Is this possible with Guice? Module: Class: Answer That is not what map binder are intended for. In your example a binding annotation would be the way to go: https://github.com/google/guice/wiki/BindingAnnotations
Bootstrapping Guice injector
I have a scenario where I will need some objects injecting at the start like logging, but then other objects injected on demand. What I don’t know is if in my console application, do I just call: in my Main function and then when I need another object, the type that I need on demand, do I use a Provider
my Google Guice method interceptor doesn’t execute but Why?
So I am testing a simple Google Guice interceptor – My Annotation – @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface AppOpsOperation { } My Interceptor public …
Guice injector in JUnit tests [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. Improve this question Using Guice, is it a good practice to get a new injector in each JUni…