You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 22:12:02