开发者

How to turn off Eclipse warning "The import is never used"?

I have a lot of this warnings in project and I woul开发者_JAVA技巧d like to turn it off. I'm not interested in removing those imports, so please don't tell me how to do it.

I'm using eclipse 3.4.2.


To change for the entire workspace:

Window > Preferences > Java > Compiler > Errors/Warnings > Unused Import > Ignore.

To override workspace settings for a single project:

Project > Properties > Java Compiler > Errors/Warnings > Unused Import > Ignore.


@SuppressWarnings("unusedImports") disables just unused imports as opposed to al unused items


Btw, one very good shortcut is ctrl+shift+o that cleans those imports automatically.

Also it is possible to put so that in every save imports are automatically organised from:

window->preference->java->editor->save actions

If you prefer to leave those imports there, it is ok. But that is to anyone else :)

Also I am not sure about 3.4 version.


If you have a file org.eclipse.jdt.core.prefs then you can add org.eclipse.jdt.core.compiler.problem.unusedImport=ignore.

When using vscode this file should be seen from the project root in a folder .settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜