​​Intellij IDEA使用教程相关系列 目录​​

步骤:Settings→Editor→General→Auto Import,如图所示

intelliJ IDEA 自动优化导入包_优化导入包

intelliJ IDEA 自动优化导入包_idea_02

选中Optimize imports on the fly和Add unambiguous imports on the fly

勾选Optimize imports on the fly 选项,IntelliJ IDEA 将在我们书写代码的时候自动帮我们优化导入的包,比如自动去掉一些没有用到的包。 

勾选Add unambiguous imports on the fly选项,IntelliJ IDEA 将在我们书写代码的时候自动帮我们导入需要用到的包。但是对于那些同名的包,还是需要手动 Alt + Enter 进行导入的