@Inject within interceptor and feature #312
-
I would like to know if it is possible to use @Inject annotation within interceptors and features |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @dinosath I assume you are referring to custom interceptors and features; the docs clearly state that: "Both feature and interceptor classes will be attempted to be loaded via CDI first, and if no CDI beans are available, then the constructor with no parameters will be invoked to instantiate each class." I would suggest you review the following link thoroughly: I did not test it, but in theory, adding both |
Beta Was this translation helpful? Give feedback.
-
Hi @dinosath Hi @shumonsharif , I was stumbling about the same issue. In my case when I set the
With the additional annotation I had to add |
Beta Was this translation helpful? Give feedback.
Hi @dinosath I assume you are referring to custom interceptors and features; the docs clearly state that:
"Both feature and interceptor classes will be attempted to be loaded via CDI first, and if no CDI beans are available, then the constructor with no parameters will be invoked to instantiate each class."
I would suggest you review the following link thoroughly:
https://quarkus.io/guides/cdi-reference
I did not test it, but in theory, adding both
@Startup
and@Singleton
annotations to your custom interceptor or feature classes should do the trick for you. Please let us know in case that doesn't work.