gpt4 book ai didi

java - checkstyle 配置期间失败 : unable to parse configuration stream

转载 作者:行者123 更新时间:2023-12-04 15:43:02 33 4
gpt4 key购买 nike

我目前正在为 maven/java 项目实现 checkstyle。由于我公司的项目太复杂而且太大,我从一个较小的项目开始只是为了测试它是否有效。到目前为止,实现情况良好。我设置了我的 checkstyle.xml将其连接到 pom.xml ,都设置好了。同样在报告部分,因为我之后想要一些输出。问题是,它想以某种方式解析某些东西,但我什至无法访问这些文件。
检查样式.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报告的文件。

最佳答案

您的 checkstyle.xml格式不正确。格式良好的 XML 文档只有一个根元素。你应该把你的 ImportOrderSuppressionXpathSingleFilter TreeWalker下的模块像这样:

<!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 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>
</module>
</module>

关于java - checkstyle 配置期间失败 : unable to parse configuration stream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57073005/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com