简体   繁体   中英

Can Eclipse auto-complete import statement without adding wildcard?

当我在 Eclipse 中输入 import 语句时,会给出自动完成选项的列表,但是当我选择一个时,它会为整个包添加一个通配符,例如org.apache.* ,但我想自动完成只是包名称并继续输入子包或类,例如org.apache.log4j.Logger

Eclipse has a setting for the number of imports needed in order to stop listing the classes one by one and use the package.* syntax instead.

You can change that setting by going to Window>Preferences>Java>Code Style>Organize Imports.

Put a large number into the edit boxes at the bottom.

Rather than typing individual import statements by hand, consider just typing the names of classes where you need them, then using Content Assist ( Ctrl + Space or Command + Space on OS X) and let Eclipse auto-insert the import statement for you automatically. It won't use a wildcard import unless you've configured it to do that at a certain threshold (see @f1sh's answer).

使用Ctrl + Space键入包名,eclipse 将显示相关包。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM