file->Settings
IDEA自动导包设置
下拉菜单选择 All,两个勾选上
Add unambiguous imports on the fly:自动导入不明确的包
Optimize imports on the fly:自动优化导入的包

IDEA自动导包设置

相关文章: