您现在的位置是:首页 > 文章详情

maven checkstyle插件报错

日期:2019-05-13点击:2158

问题:
checkstyle插件报错

详情:
我在研究docker-maven-plugin插件源码,执行
mvn clean package
报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project docker-maven-plugin: Failed during checkstyle configuration: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter: InvocationTargetException: Unable to find: checkstyle-suppressions.xml: http://www.puppycrawl.com/dtds/suppressions_1_0.dtd -> [Help 1]

配置:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> <executions> <execution> <id>validate</id> <phase>validate</phase> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> <includeTestSourceDirectory>true</includeTestSourceDirectory> </configuration> <goals> <goal>check</goal> </goals> </execution> </executions> <configuration> <linkXRef>false</linkXRef> </configuration> </plugin> 

排查:
添加参数再次执行
mvn clean package -e -X
有如下
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter

 at com.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty(AutomaticBean.java:178) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:130) at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:163) ... 25 more

Caused by: java.lang.reflect.InvocationTargetException

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2116) at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2097) at org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:435) at com.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty(AutomaticBean.java:168) ... 27 more

Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to find: checkstyle-suppressions.xml

 at com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader.loadSuppressions(SuppressionsLoader.java:147) at com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader.loadSuppressions(SuppressionsLoader.java:127) at com.puppycrawl.tools.checkstyle.filters.SuppressionFilter.setFile(SuppressionFilter.java:50) ... 35 more

Caused by: java.io.FileNotFoundException: http://www.puppycrawl.com/dtds/suppressions_1_0.dtd

 at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) 

文件http://www.puppycrawl.com/dtds/suppressions_1_0.dtd未找到
网站:http://www.puppycrawl.com
06EE02CF3A82444B9F37C0765AAAD652

解决方式:
1.找Oliver Bum要一个suppressions_1_0.dtd
2.删除checkstyle-suppressions.xml文件(会报错)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project docker-maven-plugin: Failed during checkstyle configuration: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter: InvocationTargetException: Unable to find: checkstyle-suppressions.xml -> [Help 1]
3.自己写一个,如果知道内容可以自己写一个
例如:
修改前:
<?xml version="1.0" encoding="UTF-8"?>
/p>

"-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> 



修改后:
文件:checkstyle-suppressions.xml
<?xml version="1.0" encoding="UTF-8"?>




增加文件:suppressions.dtd





原文链接:https://yq.aliyun.com/articles/702341
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章