长期使用 eclipse 和 Java。我在 Eclipse 中发现的一个问题是,似乎没有一种简单的方法来导入静态成员和方法。
即,jUnitfail()
方法来自org.junit.Assert
我每天创建几个类,然后手动添加
import static org.junit.Assert.fail;
to the import statements. This is quite annoying. I absolute LOVE using Ctrl+Shift+O to organize my imports, but it still doesn't find static
members and methods.
Also, the import does not show up in eclipse.
有趣的是,我以前见过它工作,但我不记得变量了。
所以我的问题是:
Does anybody know what I need to do to ensure that this static import is always recognized and can be found using Ctrl+Shift+O?
谢谢@qilihq。
Note:
被接受的答案不适用于我在 Eclipse 中喜欢的组织导入键盘快捷键,但适用于“悬停在”建议上。
You can use Ctrl + Shift + M, for example you want to import verify method from Mockito class then
Mockito.verify() // select verify and press Ctrl + Shift + M
这将从 Mockito 类导入 verify 静态方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)