IDEA 代码中的类添加全路径

相关环境

MacOS 10.15.3
IDEA 2019.3

问题描述

IDEA 使用过程中出现了在代码出现了 Java 类的完整包路径,比如像下面这样:

@JsonProperty(value = "ExCustomerAccounts")
private Item<ExCustomerAccounts> exCustomerAccountsItem;
@JsonProperty(value = "ExCustomerRelationship")
private Item<com.jzl.api.entity.business.excustomerdetails.onetomany.excustomerrelationship.ExCustomerRelationship> exCustomerRelationshipItem;
@JsonProperty(value = "ExCustomerRelationships")
private Item<ExCustomerRelationships> exCustomerRelationshipsItem;

问题原因

这个问题的出现是因为在 IDEA 的设置中设置了 "Use fully qualified class names" 导致的。

解决方法

更改对应的设置即可。Preferences -> Editor -> Code Style -> Java -> General,请按下方截图中的标记设置即可。

1. 取消 "Use fully qualified class names" 前的勾。

2. Use fully qualified class names in JavaDoc 后选择 "Never, use short name and add import"。

You may also like...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注