首页 > 开发程序 > Java > 正文


Jenkins构建maven项目错误,提示不符合PMD规范

10-20 10:37:30   来源:shikezhi   评论: 点击:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.6:check (default-cli) on project test-project: You have 6 PMD violations. For more details see: /home/builder/.jenkins/jobs/java-projects/workspace/test-project/target/pmd.xml -> [
 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.6:check (default-cli) on project test-project: You have 6 PMD violations. For more details see: /home/builder/.jenkins/jobs/java-projects/workspace/test-project/target/pmd.xml -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :test-project
 
首先讲一下什么是PMD:
PMD是一款采用BSD协议发布的Java程序代码检查工具。该工具可以做到检查Java代码中是否含有未使用的变量、是否含有空的抓取块、是否含有不必要的对象等。该软件功能强大,扫描效率高,是Java程序员debug的好帮手。
我这里在做打包之前是要做PMD规范检查的。这里把jenkins PMD规范检查命令放出来给大家参考,命令如下:
 
clean pmd:check install deploy -Dmaven.test.skip=true
 
 
 
下面解决PMD错误
原因:接口中多了类似public等关键字,示例如下:
package com.tangzq;
 
import java.util.Map;
 
 
public interface MyInterface {
           public Map<String, Person> query(String[] ids);
}
 
 
解决办法:去掉接口方法中的public即可,示例如下:
package com.tangzq;
 
import java.util.Map;
 
public interface MyInterface {
            Map<String, Person> query(String[] ids);
}
 

相关热词搜索:Jenkins maven项目错误

上一篇:postgresql数据库常用命令汇总 下一篇:最后一页
分享到: 收藏