【问题标题】:Maven : Invalid element name : buildMaven:无效的元素名称:构建
【发布时间】:2022-11-04 19:10:15
【问题描述】:

我是 Maven 工具的新手。我正在尝试在 Eclipse 中使用 Maven 进行自动化测试。按照 YouTube 视频的指示,我在 pom.xml 文件中添加了一些依赖项。当我在构建元素下添加插件时,我收到一条错误消息“无效的元素名称:构建”。 错误显示“*此行有多个标记

  • 元素名称无效:
  • 构建 预计会出现以下情况之一:
  • 依赖 错误指示: {http://maven.apache.org/POM/4.0.0} 带代码:
  • 格式错误的 POM D:\Eclipse\Automation\pom.xml:无法识别的标签:'build'(位置:已看到 START_TAG ...\r\n\r\n...@23:8)*"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ll.test</groupId>
  <artifactId>Automation</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Automation</name>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.6.0</version>
    <scope>test</scope>
</dependency>
    
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-chrome-driver</artifactId>
    <version>4.2.2</version>
</dependency>

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.10.1</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M7</version>
      </plugin>
    </plugins>
</build>
    
  
  </dependencies>
</project>

【问题讨论】:

  • 请在此处检查pom.xml 的构造:maven.apache.org/pom.html 您打开了标签&lt;dependencies&gt;,但没有在错误的位置关闭...标签&lt;dependencies&gt; 包含名称暗示的依赖项,但不包含部分&lt;build&gt;...&lt;/build&gt;...
  • 谢谢,在您发表评论后我注意到这是一个愚蠢的错误!现在已经解决了!

标签: eclipse maven


【解决方案1】:

你把建造标记到依赖项区域。关闭标签依赖关系在最后一个依赖之后。

...
<dependencies>
  ...
  </dependency>
</dependencies>
<build>
  ...
</build>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多