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

Maven生成Javadoc报错:未知标签问题求助

解决Javadoc生成时的"unknown tag"错误

Hey there, let's get that Javadoc build error sorted out for you! The problem you're facing when running mvn javadoc:javadoc javadoc:aggregate is caused by a tiny typo in your Javadoc comment.

错误根源

Javadoc has strict rules for its standard tags, and you used @throw instead of the correct @throws (note the trailing "s"). The tool doesn't recognize @throw as a valid tag, hence the "unknown tag" error.

修正后的代码

Here's the fixed version of your method, including a small logic fix in the error message (it currently says "b must be equal to 0" which contradicts the check for b == 0):

/** 
 * Divide two integers
 * @param a the dividend integer
 * @param b the divisor integer
 * @return the result of a divided by b, if b is not zero
 * @throws IllegalArgumentException if b is equal to 0
 */
public static int division(final int a, final int b) {
    if (b == 0) {
        throw new IllegalArgumentException("b must NOT be equal to 0");
    }
    return a / b;
}

验证修复

Once you update the Javadoc and fix that error message, re-run your Maven command:

mvn javadoc:javadoc javadoc:aggregate

The "unknown tag" error should no longer appear, and your Javadoc should generate successfully.

内容的提问来源于stack exchange,提问作者Leon

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.12 04:32:09