[英]How do I get Checkstyle to ignore final method rule on classes marked with the @Entity annotation?
Say I have classes marked with the @Entity annotation假设我有标有 @Entity 注释的类
@Entity
class User {
public String getName(String name) {
return this.name;
}
}
Checkstyle will report that the class is not built for extension and suggest marking the methods with final (or the whole class). Checkstyle 将报告 class 不是为扩展而构建的,并建议使用 final(或整个类)标记方法。 I can't do this because it's marked as an entity which can't be final.我不能这样做,因为它被标记为不能是最终的实体。
How do I get Checkstyle to ignore classes marked with @Entity for this rule?对于此规则,如何让 Checkstyle 忽略标有 @Entity 的类?
Thanks谢谢
The module you want to disable is DesignForExtension .您要禁用的模块是DesignForExtension 。 Just remove it from your configuration file.只需将其从配置文件中删除即可。
Look at the SuppressionFilter or SuppressionCommentFilter查看SuppressionFilter或SuppressionCommentFilter
Filter SuppressionFilter rejects audit events for Check errors according to a suppressions XML document in a file. Filter SuppressionFilter 根据文件中的抑制 XML 文档拒绝检查错误的审计事件。
Are you using Ant build?您使用的是 Ant 版本吗? If so, in your checkstyle target, try something like:如果是这样,在您的 checkstyle 目标中,尝试以下操作:
<checkstyle>
<fileset dir="src.dir">
<include name="**/*.java" />
<exclude name="User.java" />
</fileset>
</checkstyle>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.