使用 Spring 时如何抑制 checkstyle 消息“实用程序类不应具有默认构造函数的公共”

and*_*ant 5 java spring

在 Spring Java 项目中,我有以下类:

@SuppressWarnings({"PMD", "Checkstyle"})
@SpringBootApplication
public class ToolBoxApplication {

    public static void main(final String[] args) {
        SpringApplication.run(ToolBoxApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

使用 Jenkins 构建告诉我,我不应该在实用程序类中拥有公共或默认构造函数。

在我的 checkstyle.xml 和 Treewalker 文件中,我有

<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
<module name="SuppressWarningsHolder" />
Run Code Online (Sandbox Code Playgroud)

和模块

我试图使用抑制特定检查

@SuppressWarnings({"PMD", "checkstyle:HideUtilityClassConstructor"})

但这也不起作用。“PMD”抑制确实有效(它有效地报告了相同的错误)。

pvp*_*ran 3

抑制时需要指定小写的 checkstyle 名称。这会做

@SuppressWarnings({"PMD", "checkstyle:hideutilityclassconstructor"})
Run Code Online (Sandbox Code Playgroud)