Very nice feature of IntelliJ is auto-importing dependencies and dependencies cleanup (optimize imports), especially useful when copy pasting entire code blocks, deleting stuff etc…
Here is a screenshot of where to enable the settings and a link to IntelliJ docs…