首页 > 解决方案 > 带有重复标签的 Maven Java 错误:“配置”

问题描述

我在使用 Maven 时遇到错误。它在 VS Code 中使用该工具添加了一个依赖项,并在 . 我试图重新启动 vs 代码,因为它可能是一个错误,但显然不是。 调试错误消息:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM c:\Users\wikim\Desktop\Java\argbot\pom.xml: Duplicated tag: 'configuration' (position: START_TAG seen ...</dependencies>\r\n        <configuration>... @80:24)  @ line 80, column 24  
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (c:\Users\wikim\Desktop\Java\argbot\pom.xml) has 1 error
[ERROR]     Non-parseable POM c:\Users\wikim\Desktop\Java\argbot\pom.xml: Duplicated tag: 'configuration' (position: START_TAG seen ...</dependencies>\r\n        <configuration>... @80:24)  @ line 80, column 24 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

这是pom.xml 文件

标签: javamavenvisual-studio-code

解决方案


如果您查看错误,则显示第 80 行有问题。对于插件maven-checkstyle-plugin,您在 XML 中有两个configuration标签。我会将其更改为单个:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>${maven-checkstyle-plugin.version}</version>
    <configuration>
      <testFailureIgnore>true</testFailureIgnore>
      <configLocation>com/github/ngeor/checkstyle.xml</configLocation>
      <includeTestSourceDirectory>true</includeTestSourceDirectory>
      <skip>${skipTests}</skip>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>com.puppycrawl.tools</groupId>
        <artifactId>checkstyle</artifactId>
        <version>${checkstyle.version}</version>
      </dependency>
      <dependency>
        <groupId>com.github.ngeor</groupId>
        <artifactId>checkstyle-rules</artifactId>
        <version>${checkstyle-rules.version}</version>
      </dependency>
    </dependencies>
    <executions>
      <execution>
        <id>checkstyle</id>
        <phase>none</phase>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

推荐阅读