Guice ignoring @Nullable on injected constructor parameter

℡╲_俬逩灬. 提交于 2019-12-02 10:23:42

问题


I'm using Guice (v 3.0) and have a value that is being injected into a constructor. This value can be null, so I have annotated the parameter in the constructor with @Nullable (from javax.annotations).

public MyClass(Parameter1 p1, @Nullable Parameter2 p2) {
}

However, Guice is complaining with provision errors when it comes to initialise the class:

parameter 2 of com.abc.MyClass.<init>() is not @Nullable

I don't understand why this is not working, is there something else I need to do?


回答1:


Turned out to be an eclipse problem - wasn't refreshing my workspace properly.



来源:https://stackoverflow.com/questions/8226310/guice-ignoring-nullable-on-injected-constructor-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!