Skip to content
Advertisement

How can I supress the checkstyle message “Utility classes should not have a public of default constructor” when using Spring

In a Spring Java project I have the following class:

JavaScript

Building using Jenkins tells me that I should not have a public or default constructor in a utility class.

In my checkstyle.xml withing Treewalker file I have

JavaScript

And the module

I tried to supress the specific check using

@SuppressWarnings({“PMD”, “checkstyle:HideUtilityClassConstructor”})

but this did not work either. The “PMD” supression does work (it effectively reports the same error).

Advertisement

Answer

You need to specify checkstyle name in lower case when supressing. This will do

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement