我正在尝试执行此处显示的示例
http://pmd.sourceforge.net/pmd-5.3.0/customizing/howtowritearule.html
显示WhileLoopsMustUseBracesRule 类未找到[我认为这是初学者的标准问题之一]
尝试过的方法:
1) cd pmd-5.3.0
2) created WhileLoopsMustUseBracesRule.java and ruleset.xml as per shown in the page.
3) javac -cp [all the required jar files seperated by ; since it is windows pc ] WhileLoopsMustUseBracesRule.java
4) bin/pmd.bat -d [code on which pmd has to check the rule] -f xml -R ruleset.xml
上述步骤给我没有找到类错误,开发人员评论说这些步骤有效 [http://sourceforge.net/p/pmd/discussion/188192/thread/7a34d224/ ]
如果我遗漏了什么,请告诉我。
我也尝试将类文件直接添加到类路径中 尝试过其他方法:
1) compiled the WhileLoopsMustUseBracesRule.java file and got the .class file.
2) created a jar using jar -cf jar_name jar_file command
3) added that jar file in the class path , using set CLASSPATH and also tried adding directly in the batch file used to run PMD i.e. pmd.bat
请帮忙!
最佳答案
我找到了解决方案!
必须使用单独设置 CLASSPATH
set CLASSPATH=path\to\my\classfile
然后在批处理中我必须添加 %CLASSPATH% ,否则使用 -cp 会重置我猜的类路径。这对我有用。
谢谢
关于java - 在 PMD 中添加自定义规则 - 未找到类问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29483785/