【发布时间】:2019-11-26 02:52:13
【问题描述】:
我目前正在为 maven/java 项目实现 checkstyle。由于我公司的项目过于复杂而且太大,我从一个较小的项目开始只是为了测试它是否有效。到目前为止,执行情况良好。我设置了我的checkstyle.xml,将其连接到pom.xml,全部设置完毕。同样在报告部分,因为我之后想要一些输出。问题是,它想解析某些东西,但我什至无权访问这些文件。
CheckStyle.xml:
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="AvoidStaticImport">
<property name="excludes"
value="java.lang.System.out,java.lang.Math.*" />
</module>
</module>
</module>
<module name="ImportOrder">
<property name="groups" value="*,javax,java"/>
<property name="ordered" value="true"/>
<property name="separated" value="false"/>
<property name="option" value="top"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="SuppressionXpathSingleFilter">
<property name="checks" value="ImportOrder"/>
<property name="message" value="^'java\..*'.*"/>
</module>
pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting><!---->
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
堆栈跟踪:
[INFO] --- maven-checkstyle-plugin:3.1.0:check (default) @ testHelloWorld ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.464 s
[INFO] Finished at: 2019-07-17T11:34:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.0:check (default) on project testHelloWorld: Failed during checkstyle execution: Failed during checkstyle configuration: unable to parse configuration stream - The markup in the document following the root element must be well-formed.:11:3 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.0:check (default) on project testHelloWorld: Failed during checkstyle execution
原因:org.apache.maven.plugin.MojoExecutionException: checkstyle 执行失败
原因:org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException: checkstyle配置失败
原因:com.puppycrawl.tools.checkstyle.api.CheckstyleException:无法解析配置流 - 根元素后面的文档中的标记必须格式正确。:11:3
还有: 原因:org.xml.sax.SAXParseException:文档中根元素之后的标记必须格式正确。
我收到了checkstyle-result.xml,但它是空的。在我得到一个空的 XML 模板之前,它可以正常工作,没有任何待办事项。我仍然希望报告有一个checkstyle.html 文件。
【问题讨论】:
标签: java html xml maven checkstyle