I just announced the new Spring Boot 2 material, coming in REST With Spring:

>> CHECK OUT THE COURSE

1. Overview

This brief tutorial will describe each option of IntelliJ IDEA’s ‘auto-import’ feature.

2. Auto-import

There are several options in IntelliJ IDEA that we may configure in Settings > Editor > Auto Import:

Let’s review each of these options.

2.1. Show Import Popup

When enabled, IDEA will underline a class reference in our code and suggest an import to add:

If there are several options to choose from, Idea will let us choose an import from a list of alternatives:

2.2. Optimize Imports on the Fly

This one will make IDEA remove unused imports automatically and rearrange others according to the ‘Code Style’ preferences.

2.3. Add Unambiguous Imports on the Fly

Also, there is a way to automatically add an import as we add references to classes that need to be imported.

2.4. Show Import Suggestions for Static Methods and Fields

Our final option will enable the import popup feature for statics.

However, note that turning only this option on (without ‘Show import popup’) will not enable import suggestions for classes:

3. Conclusion

Some developers prefer to have total control over the imports in their classes, others rely on the IDE to handle this technical task.

Either of them may benefit from various configuration options that IntelliJ IDEA IDE has, including those for importing behavior.

I just announced the new Spring Boot 2 material, coming in REST With Spring:

>> CHECK OUT THE LESSONS