如何配置IntelliJ IDEA使自动生成的JavaDoc包含参数与返回值类型
在IntelliJ IDEA中配置自动生成含参数/返回值类型的Java文档
可以通过修改IDEA的JavaDoc模板实现需求,具体操作步骤如下:
- 打开IDEA设置界面:Windows/Linux按
Ctrl+Alt+S,Mac按Cmd+, - 依次导航到
Editor→File and Code Templates→Includes选项卡 - 找到
JavaDoc Parameter模板,将其内容替换为:@param ${param.name} (${param.type}) ${param.description} - 找到
JavaDoc Return模板,将其内容替换为:@return ${type} ${description} - 点击
Apply和OK保存配置
配置完成后,在方法上方输入/**并按下回车,IDEA就会自动生成符合你要求格式的Java文档,示例效果:
/** * Calculates the sum of two numbers * * @param a (int) the first number * @param b (int) the second number * @return int the sum of a and b */ public int add(int a, int b) { return a + b; }
内容的提问来源于stack exchange,提问作者3nondatur
相关产品推荐
相关产品推荐

