【问题标题】:Adding custom rules in PMD - class not found issue在 PMD 中添加自定义规则 - 找不到类问题
【发布时间】:2015-04-07 13:30:22
【问题描述】:

我正在尝试执行此处显示的示例

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

请帮忙!

【问题讨论】:

    标签: java pmd


    【解决方案1】:

    我找到了解决办法!

    必须单独设置 CLASSPATH 使用

    set CLASSPATH=path\to\my\classfile
    

    然后在批处理中我必须添加 %CLASSPATH% ,否则使用 -cp 正在重置我猜的类路径。这对我有用。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-03
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 2017-03-10
      相关资源
      最近更新 更多