问题描述

  • Intellij Idea工具在java文件中,经常会自动导入import java.utils.*
  • 这样的导入方式,导致引入不必要的包,使得类的体积变大
  • 不推崇导入*这样的做法!

问题解决

  • 选择 Editor->Code Style->Java->Imports   

IDEA:修改JAVA文件自动引入import.*包

  • 修改Class count和Names count属性

Class count to use import with '*':设置500
Names count to use static import with '*':设置300

此处设置为500所表示的含义为:设置:当同时导入相同的包的 类的次数超过500次时,则自动更改为*的方式进行导入,不超过该所设定设置时,则默认为导入当前包中的类!

  • 设置以后再使用
Ctrl+Alt+O 优化导入的类和包时,则不会再自动更改为import.*的方式

相关文章:

  • 2021-05-28
  • 2022-01-06
  • 2022-02-22
  • 2021-07-26
  • 2021-05-09
  • 2021-07-23
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2021-11-29
  • 2021-10-18
相关资源
相似解决方案