Maven checkstyle error : Expected @param tag for '<T>'

Maven checkstyle error : Expected @param tag for '<T>'

我有以下泛型类型的方法,但是当我 运行 maven checkstyle(maven-checkstyle-plugin, 2.121) 它 在 Maven 构建过程中不断给我 Expected @param tag for '<T>' 错误消息。我该如何克服这个问题?

/**
 * Read in specified type of object from request body.
 * @param request The HttpServletRequest
 * @param expected The expected type T
 * @return <T> specified type of object
 */
public <T extends Object> T getExpectedValue(
    final HttpServletRequest request, final Class<T> expected)

我使用以下方法关闭了通用参数标签,但它没有用,我在上面也提到了 java 文档。

<module name="JavadocType">
    <property name="allowMissingParamTags" value="true"/>
</module>

您将 T 的 @param 标记添加到您的 Javadoc。

像这样:

/**
 * ... other comments here ...
 * @param T The expected class of the value.
 * @param request ... other comments here ...
 * @param expected ... other comments here ...
 * @return ... other comments here ...
 */
public <T extends Object> T getExpectedValue(
    final HttpServletRequest request, final Class<T> expected)

如果您没有使用 Javadoc,那么您可能不应该启用 Javadoc 警告。

告诉你你没有为方法类型参数编写 javadoc:

/**
 * ...
 * @param <T> This is the type parameter
 * @param ....
 */
 public <T extends Object> T getExpectedValue(
        final HttpServletRequest request, final Class<T> expected)

生成的 javadoc 将在 header:

中包含如下部分
Type Parameters: 
    T - This is the type parameter