无法在现有的 pom.xml 中添加 maven 编译器和 surefire 插件

问题描述

作为 maven 新手,我想在 pom.xml 中添加以下插件依赖,有人可以帮我吗

  • 需要添加这个

    org.apache.maven.plugins Maven 编译器插件 2.3.2. 1.7 1.7 org.apache.maven.plugins maven-surefire-plugin 2.12 真的 测试文件
  • 退出 Pom.xml

    4.0.0 www.asr.com 阿斯尔 0.0.1-快照

     <dependencies>
         <dependency>
             <groupId>org.seleniumhq.selenium</groupId>
             <artifactId>selenium-java</artifactId>
             <version>3.141.59</version>
         </dependency>
    
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
             <version>7.3.0</version>
             <scope>compile</scope>
         </dependency>
     </dependencies>
    

解决方法

你必须在标签内添加你的插件。

例如:

  <build>
    <plugins>    
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>${asm.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>${asm.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <useFile>false</useFile>
          <excludes>
            <exclude>**/integration/**</exclude>
          </excludes>
          <includes>
            <include>**/*Test.java</include>
            <include>**/*Spec.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>