欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Maven环境搭建(学习笔记记录)

程序员文章站 2022-03-22 13:12:02
...

Java环境,eclipse编译器等环境就绪(for Windows 10):
1、 maven:http://maven.apache.org/download.cgi
选择如图版本:
Maven环境搭建(学习笔记记录)

2、解压zip包到本地,配置环境变量
MAVEN_HOME:D:\Maven\apache-maven-3.5.4
Path:追加;%MAVEN_HOME%\bin到后面
3、验证maven环境
cmd命令行验证:mvn -v
出现如下界面,环境配置成功。
Maven环境搭建(学习笔记记录)

4、在eclipse中配置maven
1)打开eclipse》点击Window》点击Preferences
Maven环境搭建(学习笔记记录)
2)点击Maven》选择installations》从本地路径引入刚才解压的maven文件(图中已加入)
Maven环境搭建(学习笔记记录)

3)同时注意配置User Settings》选择本地目录D:\Maven\apache-maven-3.5.4\conf\settings.xml引入
Maven环境搭建(学习笔记记录)
4)修改settings.xml文件
54行添加:

  <localRepository>C:\maven\repository</localRepository>

161行添加:

<mirror>
	 <id>aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>aliyun Maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>

5)在第3)步骤操作的界面点击update settings,配置完成。

5、创建maven项目
在eclipse中点击new》project》maven project
Maven环境搭建(学习笔记记录)
点击next》next》next
Maven环境搭建(学习笔记记录)
点击finish 创建完成。

6、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:组织 id(类似包名), artifactId:project name , version:default development 
		version , packaging:default jar -->
	<groupId>com.test.practice</groupId>
	<artifactId>maventest</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>maventest</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<xmlFileName>testng.xml</xmlFileName>
	</properties>

	<!-- 依赖的jar包可从百度搜索,例如:maven testng -->
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.testng/testng -->
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<version>6.14.3</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-java</artifactId>
			<version>3.14.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.uncommons/reportng 依赖ReportNg,关联TestNg -->
		<dependency>
			<groupId>org.uncommons</groupId>
			<artifactId>reportng</artifactId>
			<version>1.1.4</version>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.testng</groupId>
					<artifactId>testng</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!-- 依赖Guice -->
		<dependency>
			<groupId>com.google.inject</groupId>
			<artifactId>guice</artifactId>
			<version>3.0</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.apache.poi/poi 依赖poi -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.17</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl 依赖jxl -->
		<dependency>
			<groupId>net.sourceforge.jexcelapi</groupId>
			<artifactId>jxl</artifactId>
			<version>2.6.12</version>
		</dependency>
	</dependencies>
</project>


相关标签: 自动化测试