idea编译项目时,出现如下报错:
[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check(validate)onprojectdevops-brain:Failedduringcheckstyleconfiguration:Cannotsetproperty'cacheFile'to'F:\Copote\Code\devops-brain\devops-brain\target/checkstyle-cachefile':InvocationTargetException:com/谷歌/common/io/Flushables:com.谷歌.common.io.Flushables->[Help1]
进入pom.xml所在目录,如图:
执行如下命令,查看详细日志:
mvncleanpackage-e-X
[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check(validate)onprojectdevops-brain:Failedduringcheckstyleconfiguration:Cannotsetproperty'cacheFile'to'target/cachefile':InvocationTargetException:com/谷歌/common/io/Flushables:com.谷歌.common.io.Flushables->[Help1]org.apache.maven.lifecycle.LifecycleExecutionException:Failedtoexecutegoalorg.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check(validate)onprojectdevops-brain:Failedduringcheckstyleconfigurationatorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)...atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Causedby:org.apache.maven.plugin.MojoExecutionException:Failedduringcheckstyleconfigurationatorg.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:534)...atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Causedby:com.puppycrawl.tools.checkstyle.api.CheckstyleException:Cannotsetproperty'cacheFile'to'target/cachefile'atcom.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty(AutomaticBean.java:237)atcom.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:191)...atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Causedby:java.lang.reflect.InvocationTargetExceptionatsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)...atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Causedby:java.lang.NoClassDefFoundError:com/谷歌/common/io/Flushablesatcom.puppycrawl.tools.checkstyle.PropertyCacheFile.flushAndCloseOutStream(PropertyCacheFile.java:167)...Causedby:java.lang.ClassNotFoundException:com.谷歌.common.io.Flushablesatorg.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)...atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)[ERROR][ERROR]Re-runMavenusingthe-Xswitchtoenablefulldebuglogging.[ERROR][ERROR]Formoreinformationabouttheerrorsandpossiblesolutions,pleasereadthefollowingarticles:[ERROR][Help1]http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException定位到日志:
Causedby:java.lang.ClassNotFoundException:com.谷歌.common.io.Flushables
这个类在如下依赖jar包中,在pom中添加如下依赖:
<dependency><groupId>com.谷歌.guava</groupId><artifactId>guava</artifactId><version>20.0</version></dependency>如果依赖引入后还不行,请删除本地maven库中guava目录,重新导入:
重新编译项目,如果没其他错误,即可成功。不幸的是,作者编译后继续报错如下:
[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check(validate)onprojectdevops-brain-manager-bean:Failedduringcheckstyleexecution:Thereare8errorsreportedbyCheckstyle8.18with../../code-style/checkstyle.xmlruleset.->[Help1]
继续执行如下命令,查看详细日志:
mvncleanpackage-e-X
如图:
[INFO]寮?濮嬫鏌モ?︹??[ERROR]F:\Copote\Code\...\dto\AlertRuleDto.java:7:4:鏈煡鏍囩'description'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\AlertRuleEntity.java:7:4:鏈煡鏍囩'description'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\AlertsEntity.java:7:4:鏈煡鏍囩'description'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\BaseEntity.java:12:47:WhitespaceAround:'{'isnotprecededwithwhitespace.[WhitespaceAround][ERROR]F:\Copote\Code\...\entity\HostConfigEntity.java:11:49:WhitespaceAround:'{'isnotprecededwithwhitespace.[WhitespaceAround][ERROR]F:\Copote\Code\...\entity\HostEntity.java:7:4:鏈煡鏍囩'Author'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\HostEntity.java:8:4:鏈煡鏍囩'Date'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\HostEntity.java:9:4:鏈煡鏍囩'Version'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\HostEntity.java:10:4:鏈煡鏍囩'Description'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\HostTagEntity.java:6:缂哄皯Javadoc銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\MetricEntity.java:8:4:鏈煡鏍囩'description'銆?[JavadocType][ERROR]F:\Copote\Code\...\entity\MetricTemplateEntity.java:7:4:鏈煡鏍囩'description'銆?[JavadocType]妫?鏌ュ畬鎴愩??[INFO]------------------------------------------------------------------------...Causedby:org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException:Thereare12errorsreportedbyCheckstyle8.18with../../code-style/checkstyle.xmlruleset.atorg.apache.maven.plugins.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:309)定位到日志:
Thereare8errorsreportedbyCheckstyle8.18with../../code-style/checkstyle.xmlruleset.->[Help1]
原因是存在多处代码不符合风格。逐个检查修改即可。