Guice在注入的构造函数参数上忽略@Nullable [英] Guice ignoring @Nullable on injected constructor parameter

查看:184
本文介绍了Guice在注入的构造函数参数上忽略@Nullable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Guice(v 3.0)并且有一个值被注入到构造函数中。这个值可以为null,所以我在构造函数中使用@Nullable(来自javax.annotations)注释了该参数。

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) {
}

然而,Guice在初始化课程时抱怨提供错误:

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?

推荐答案

原来是一个日食问题 - 没有正确刷新我的工作区。

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

这篇关于Guice在注入的构造函数参数上忽略@Nullable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆