Maven 环境配置

1.安装maven

Installing Maven

         1)Unpack the archive where you would like to store the binaries, eg:

                  Unix-basedoperating systems (Linux, Solaris and Mac OS X)

                          tarzxvf apache-maven-3.x.y.tar.gz

                  Windows

                          unzipapache-maven-3.x.y.zip

         2)A directory called "apache-maven-3.x.y" will be created.

         3)Add the bin directory to your PATH, eg:

                  Unix-basedoperating systems (Linux, Solaris and Mac OS X)

                          exportPATH=/usr/local/apache-maven-3.x.y/bin:$PATH

                  Windows

                          setPATH="c:\program files\apache-maven-3.x.y\bin";%PATH%

         4)Make sure JAVA_HOME is set to the location of your JDK

         5)Run "mvn --version" to verify that it is correctly installed.

大意翻译及操作:

Step1下载,如下图

Step2: linux系统下:解压maven-3.5.3-bin.tar.gz文件到某个路径(如:/home/zm/JavaSoft/maven-3.5.3

Windowns系统下:解压maven-3.5.3-bin.zip文件到某个路径

Step3创建M2_HOME指向刚刚解压后的目录(环境配置)

linux系统:配置Maven环境:

sudo vim /etc/profile
G
o
export M2_HOME=/home/zm/JavaSoft/maven-3.5.3
export PATH=$PATH:$M2_HOME/bin
:wq
/etc/profile

Windows配置Maven环境:系统-高级-环境变量【使用用户变量】

M2_HOME=D:\JavaSoft\maven3.5.3
PATH=%PATH%;%M2_HOME%\bin
Step4查看maven是否安装好。
控制台执行mvn--v命令

The resultshould look similar to

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: D:\java\maven\apache-maven-3.5.3\bin\..
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: D:\java\jdk\jdk1.8.0_162\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

自己Windows 10环境配置成功如下:

MAVEN_HOME=D:\Java\maven\apache-maven-3.5.3
path=%path%;%MAVEN_HOME%\bin

注意:maven要和JDK在同一个目录级别,查看maven是否配置成功

2.maven 仓库配置

1.首先配置下maven的库资源文件的存放路径:

1)$M2_HOME/conf/settings.xml:(/home/zm/JavaSoft/apache-maven-3.5.3/conf/settings.xml)配置本地仓库:<localRepository>(<localRepository>/home/zm/.m2/repository</localRepository>)

本地仓库配置过程中,插件和依赖包下载跟网络有关(可能Maven仓库:http://mvnrepository.com/在外网的原因)

2) 配置阿里的Maven仓库

执行maven命令

ArchetypeCatalog

This isa reference for the Archetype Catalog descriptor.
Theseare standard catalogfiles which containinformation about Archetypes so that users can be presented with a list ofarchetypes from any number of catalogs to generate new projects.
TheArchetype Plugin knows by default its internal catalog. It also knows about thelocal and remote catalogs:
            local represents(描述) the ~/.m2/archetype-catalog.xmlcatalog file,           
            remote represents thehttp://repo.maven.apache.org/maven2/archetype-catalog.xml catalog file.
TheArchetype Plugin can also read catalogs from filesystem/HTTP by providing thepath/URL of a catalog file or of a directory containing an archetype-catalog.xml file.
<archetype-catalog xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd">           
           <archetypes>
                <archetype>
                    <groupId/>
                    <artifactId/>
                    <version/>
                    <repository/>
                    <description/>
                </archetype>
            </archetypes>
</archetype-catalog>

Maven阿里云配置

LINUX系统下阿里云配置:

$M2_HOME/conf/settings.xml:(/home/zm/JavaSoft/apache-maven-3.3.9/conf/settings.xml),进行如下配置:

Windows 系统下阿里云maven配置如下:(可以使用)

 <mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyunmaven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>

Maven私服配置(一笔带过)

Nexus私服搭建

第一步:下载nexus-webapp-1.9.2.4.war包,然后拷贝到tomcat下的webapps目录中

第二步:启动tomcat 默认登录账户密码为: admin  admin123

第三步:访问http://localhost:8080/项目名称/

Nexus仓库的默认的地址, nexus-2.1.2\WEB-INF\plexus.properties进行配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值