maven环境配置和本地仓库位置的指定

来源:互联网 发布:淘宝客速成 编辑:程序博客网 时间:2024/04/29 04:13

1.在maven官网http://maven.apache.org/download.cgi下载指定版本,解压到C:\盘根目录下

2.配置环境变量

  MAVEN_HOME     =>     C:\apache-maven-3.5.0

  path     =>     %MAVEN_HOME%\bin;

3.在控制台输入mvn -v命令进行测试

4.接下来更改本地仓库的位置,在C:\apache-maven-3.5.0\conf目录下找到settings.xml配置文件,增加或修改localRepository配置项

 <localRepository>D:/maven_repository</localRepository>

5.在Eclipse工具中,通过preferences-Maven-user settings选项中配置本地仓库,如下图所示。


6.在Eclipse工具中创建一个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/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.jcuckoo</groupId><artifactId>test</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>test Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-io</artifactId><version>1.3.2</version><scope>test</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency></dependencies><build><finalName>test</finalName></build></project>

7.右键项目,run as-Maven install安装资源包


原创粉丝点击