In Eclipse, you press CTRL + SHIFT + O “Organize Imports” to import packages automatically. For IntelliJ IDEA, if you press CTRL + ALT + O “Optimize Imports”, it just removes some unused imports, never imports any package. And the worst is you need click on the class name and press ALT + ENTER keys to import the package one by one.

Solution
The IDEA is working a bit differently, the “unambiguous imports” are imported on the fly, and you need to enable this feature manually.

File –>> Settings –>> Editor –>> General –>> Auto Import –>> Checked these options :

Add unambiguous imports on the fly
Optimize imports on the fly
Eclipse Ctrl + Shift + O in IntelliJ IDEA

Note
For ambiguous imports (same class name in a different package), you still need click on the class name and press ALT + ENTER keys to import the package manually.

相关文章:

  • 2021-12-01
  • 2021-04-16
  • 2021-12-20
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
猜你喜欢
  • 2021-09-26
  • 2021-07-07
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案