• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin

武飞扬头像
leboop-L
帮助3

idea编译项目时,出现如下报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (validate) on project devops-brain: Failed during checkstyle configuration: Cannot set property 'cacheFile' to 'F:\Copote\Code\devops-brain\devops-brain\target/checkstyle-cachefile': InvocationTargetException: com/谷歌/common/io/Flushables: com.谷歌.common.io.Flushables -> [Help 1]

学新通

 进入pom.xml所在目录,如图:

学新通

执行如下命令,查看详细日志:

mvn clean package -e -X
  1.  
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (validate) on project devops-brain: Failed during checkstyle configuration: Cannot set property 'cacheFile' to 'target/c
  2.  
    achefile': InvocationTargetException: com/谷歌/common/io/Flushables: com.谷歌.common.io.Flushables -> [Help 1]
  3.  
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (validate) on project devops-brain: Failed during checkstyle configurati
  4.  
    on
  5.  
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
  6.  
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
  7.  
        ...
  8.  
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
  9.  
    Caused by: org.apache.maven.plugin.MojoExecutionException: Failed during checkstyle configuration
  10.  
        at org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.execute (CheckstyleViolationCheckMojo.java:534)
  11.  
        ...
  12.  
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
  13.  
    Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Cannot set property 'cacheFile' to 'target/cachefile'
  14.  
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty (AutomaticBean.java:237)
  15.  
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure (AutomaticBean.java:191)
  16.  
        ...
  17.  
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
  18.  
    Caused by: java.lang.reflect.InvocationTargetException
  19.  
        at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
  20.  
        ...
  21.  
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
  22.  
    Caused by: java.lang.NoClassDefFoundError: com/谷歌/common/io/Flushables
  23.  
        at com.puppycrawl.tools.checkstyle.PropertyCacheFile.flushAndCloseOutStream (PropertyCacheFile.java:167)
  24.  
        ...
  25.  
    Caused by: java.lang.ClassNotFoundException: com.谷歌.common.io.Flushables
  26.  
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
  27.  
        ...
  28.  
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
  29.  
    [ERROR]
  30.  
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  31.  
    [ERROR]
  32.  
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
  33.  
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
学新通

定位到日志:

Caused by: java.lang.ClassNotFoundException: com.谷歌.common.io.Flushables

这个类在如下依赖jar包中,在pom中添加如下依赖:

  1.  
    <dependency>
  2.  
    <groupId>com.谷歌.guava</groupId>
  3.  
    <artifactId>guava</artifactId>
  4.  
    <version>20.0</version>
  5.  
    </dependency>

如果依赖引入后还不行,请删除本地maven库中guava目录,重新导入: 

学新通

重新编译项目,如果没其他错误,即可成功。不幸的是,作者编译后继续报错如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (validate) on project devops-brain-manager-bean: Failed during checkstyle execution: There are 8 errors reported by Checkstyle 8.18 with ../../code-style/checkstyle.xml ruleset. -> [Help 1]
 

继续执行如下命令,查看详细日志:

mvn clean package -e -X

如图:

  1.  
    [INFO] 寮?濮嬫鏌モ?︹??
  2.  
    [ERROR] F:\Copote\Code\...\dto\AlertRuleDto.java:7:4: 鏈煡鏍囩 'description' 銆? [JavadocType
  3.  
    ]
  4.  
    [ERROR] F:\Copote\Code\...\entity\AlertRuleEntity.java:7:4: 鏈煡鏍囩 'description' 銆? [Javad
  5.  
    ocType]
  6.  
    [ERROR] F:\Copote\Code\...\entity\AlertsEntity.java:7:4: 鏈煡鏍囩 'description' 銆? [JavadocT
  7.  
    ype]
  8.  
    [ERROR] F:\Copote\Code\...\entity\BaseEntity.java:12:47: WhitespaceAround: '{' is not preceded wi
  9.  
    th whitespace. [WhitespaceAround]
  10.  
    [ERROR] F:\Copote\Code\...\entity\HostConfigEntity.java:11:49: WhitespaceAround: '{' is not prece
  11.  
    ded with whitespace. [WhitespaceAround]
  12.  
    [ERROR] F:\Copote\Code\...\entity\HostEntity.java:7:4: 鏈煡鏍囩 'Author' 銆? [JavadocType]
  13.  
    [ERROR] F:\Copote\Code\...\entity\HostEntity.java:8:4: 鏈煡鏍囩 'Date' 銆? [JavadocType]
  14.  
    [ERROR] F:\Copote\Code\...\entity\HostEntity.java:9:4: 鏈煡鏍囩 'Version' 銆? [JavadocType]
  15.  
    [ERROR] F:\Copote\Code\...\entity\HostEntity.java:10:4: 鏈煡鏍囩 'Description' 銆? [JavadocTy
  16.  
    pe]
  17.  
    [ERROR] F:\Copote\Code\...\entity\HostTagEntity.java:6: 缂哄皯 Javadoc 銆? [JavadocType]
  18.  
    [ERROR] F:\Copote\Code\...\entity\MetricEntity.java:8:4: 鏈煡鏍囩 'description' 銆? [JavadocT
  19.  
    ype]
  20.  
    [ERROR] F:\Copote\Code\...\entity\MetricTemplateEntity.java:7:4: 鏈煡鏍囩 'description' 銆? [
  21.  
    JavadocType]
  22.  
    妫?鏌ュ畬鎴愩??
  23.  
    [INFO] ------------------------------------------------------------------------
  24.  
    ...
  25.  
    Caused by: org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException: There are 12 errors reported by Checkstyle 8.18 with ../../code-style/checkstyle.xml ruleset.
  26.  
    at org.apache.maven.plugins.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle (DefaultCheckstyleExecutor.java:309)
学新通

定位到日志:

There are 8 errors reported by Checkstyle 8.18 with ../../code-style/checkstyle.xml ruleset. -> [Help 1]

原因是存在多处代码不符合风格。逐个检查修改即可。

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfeeehg
系列文章
更多 icon
同类精品
更多 icon
继续加载