Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to stop intellij from deleting imports like "import javax.servlet.http.*;"? [duplicate]

I'm working with intelliJ and my problem is when I start to import some temporary unused packages into my class file intellij delete those line within a second.

how can I turn off this not so nice feature?

like image 600
Seyed Vahid Hashemi Avatar asked Nov 25 '22 21:11

Seyed Vahid Hashemi


2 Answers

Disable File | Settings | Editor | General | Auto Import | Optimize imports on the fly.

Normally you don't need to add imports manually, IDEA does it for you.

like image 142
CrazyCoder Avatar answered Nov 27 '22 10:11

CrazyCoder


For Scala developers: you can have enabled

Settings > Editor > General > Auto Import > Optimize imports on the fly

but add exclusions into

Settings > Editor > Code Style > Scala > Imports always marked as used:

enter image description here

like image 21
Sasha Avatar answered Nov 27 '22 10:11

Sasha