1、maven下载
配置环境变量

配置path

配置完成后打开cmd,输入mvn -v,测试是否安装成功
2、在eclipse中安装maven
打开eclipse的preference,点击maven->Installations,在打开的对话框里面点击add,下图中我是已经添加上了

从电脑上选择maven路径点击确定。Finnish完成

完成后把选择的maven前的复选框选择,apply一下。这个时候maven就已经安装到eclipse里面了

maven是一个方便我们管理jar包的工具,我们需要用到的jar包都是从maven的中央仓库里下载的,当我们下载过一次之后就可以在我们的本地仓库中导入jar包
3、配置maven本地仓库
第一步:你首先需要找到你的maven解压文件夹,然后打开conf子文件夹,然后编辑settings.xml,下图标红的地方修改成你自己的仓库路径

第二步:回到eclipse中点击window再点击preferences
选择maven的setting目录,自动会带出仓库名称,点击应用即可。

4、eclipse里创建maven项目
选择maven Project 点击next ,在点击next

选择下面默认的点击next

输入框内信息后,点击finish,项目创建完成。

5、修改pom文件
<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.carcoo</groupId>
<artifactId>carcooAuto</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>carcooAuto</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.carcoo.carcooAuto.Login</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
更新之后,右键选择maven--updata Project
网友评论