Search code examples
intellij-idea

Auto import annotations in IntelliJ


Is there a way to auto import annotations in IntelliJ? When I place the cursor on @Entity annotation and press ALT+Enter. I don't find a option to add:

import javax.persistence.Entity;

Does any configuration need to be done to enable it?

enter image description here


Solution

  • Inside of your editor preferences (open using shortcuts ⌘, (macOS), or Ctrl+Alt+S (Windows/Linux)).

    Go to Editor > General > Auto Import, be sure the correct values are checked. It should look similar to this: enter image description here