敲代码的兔子

导航

1TestNG及Maven安装

通过Update Site安装:

通过update site也可以进行插件的安装,方法是:在Eclipse中点击Help菜单,选择Install New Software选项,在弹出页面中输入安装地址 http://beust.com/eclipse即可安装。

 

点击Next下载插件;

Maven安装:

在C:\Users\Administrator\.m2目录下(Administrator为本机用户名)新建settings.xml,进行Maven的配置,setting.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <!-- 本地仓库的位置 -->
    <localRepository>C:\Users\Administrator\.m2\repository</localRepository>
    
    <!-- 阿里云镜像 -->
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <!-- https://maven.aliyun.com/repository/public/ -->
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>

    <!-- 配置: java8, 先从阿里云下载, 没有再去私服下载  -->
    <!-- 20190929 hepengju 测试结果: 影响下载顺序的是profiles标签的配置顺序(后面配置的ali仓库先下载), 而不是activeProfiles的顺序 -->
    <profiles>
        <!-- 全局JDK1.8配置 -->
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
</settings>

然后打开eclipse-Window-Preferences-Maven-User Settings页面-配置User Settings的路径,如果本页面提示异常,则setting.xml的结构有问题

然后创建一个Maven项目:

 

 

 

 创建完的项目结构是这样的:

 

 然后打开pom.xml配置信息:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.testrabbit</groupId>
  <artifactId>TestNGRabbit</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>TestNG1</name>

<dependencies>
      <dependency>
          <groupId>org.testng</groupId>  <!-- 中央仓库的testng jar路径,即阿里云testng路径为-->
          <artifactId>testng</artifactId>  <!-- http://maven.aliyun.com/nexus/content/groups/public/org/testng/testng -->
          <version>6.14.3</version>
          <scope>test</scope>
      </dependency>
  </dependencies>
  
  </project>

 

 

 

粗体字为新增的配置信息,groupId和artifactId为阿里云仓库对应的信息,配置完保存后,系统会自动下载对应的版本的jar包

 

posted on 2020-07-05 12:20  敲代码的兔子  阅读(284)  评论(0编辑  收藏  举报