idea版本:IntelliJ IDEA 2018.1.2

Settings    --->    Editor    --->    General    --->    Auto Import 勾选以下两个选项:

add unambiguous imports on the fly                    说白了就是自动导入缺少的包
optimize imports on the fly(for current project)    说白了即使去掉当前没有用到的包

idea自动导包设置

相关文章: