Settings→Editor→General→Auto Import 然后勾选Add unambiguous imports on the fly以及Optimize imports on the fly 这样设置可以自动添加包以及删除无用包