How to remove unused imports from Eclipse

有什么方法可以使用Eclipse IDE自动删除项目中所有未使用的导入(用警告信号通知)?


I just found the way. Right click on the desired package then Source -> Organize Imports .

Shortcut keys:

  • Windows: Ctrl + Shift + O
  • Mac: Cmd + Shift + O

  • 您可以通过按Ctrl + Shift + O直接使用快捷键


    I know this is a very old thread. I found this way very helpful for me:

  • Go to Window → Preferences → Java → Editor → Save Actions.
  • Check the option "Perform the selected actions on save".
  • Check the option "Organize imports".
  • Now every time you save your classes, eclipse will take care of removing the unused imports.

    链接地址: http://www.djcxy.com/p/90586.html

    上一篇: 加速IntelliJ

    下一篇: 如何从Eclipse中删除未使用的导入