『搭建中小型互联网公司后台服务架构』二、后台服务工具maven安装配置

后台服务工具maven:maven安装配置

1、  maven下载

下载地址:https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

2、  解压配置全局变量

用工具进行解压。

全局变量:/etc/profile

用户变量:~/.bash_profile

   export M3=/Users/heimabb/Documents/maven/apache-maven-3.3.9

export PATH=$PATH:$M3/bin

验证:

命令:mvn -version

Apache Maven 3.3.9(bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)

Maven home:/Users/heimabb/Documents/maven/apache-maven-3.3.9

3、maven本地资源库设置

主要讲解settings.xml的配置,以及本地资源库的设置
maven的配置文件settings.xml存在于两个地方:

1.安装的地方:${M3_HOME}/conf/settings.xml  全局配置

2.设置

  <localRepository>D:/java/mvn_repository</localRepository>


  <mirrors>
        <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>central</mirrorOf>
            <name>Nexus Aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>


    <profiles>
        <profile>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <name>local private nexus</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <name>local private nexus</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>

    </profiles>

Maven里面mirror元素和repository元素的作用

  mirror 是做什么的? 
  repository是做什么的? 

  2者有什么联系和区别呢?

简单点来说,repository就是个仓库。maven里有两种仓库,本地仓库和远程仓库。远程仓库相当于公共的仓库,大家都能看到。本地仓库是你本地的一个山寨版,只有你看的到,主要起缓存作用。当你向仓库请求插件或依赖的时候,会先检查本地仓库里是否有。如果有则直接返回,否则会向远程仓库请求,并做缓存。你也可以把你做的东西上传到本地仓库给你本地自己用,或上传到远程仓库,供大家使用。 

远程仓库可以在工程的pom.xml文件里指定,楼上两位已经列的很清楚了。如果没指定,默认就会把下面这地方做远程仓库,即默认会到http://repo1.maven.org/maven2这个地方去请求插件和依赖包。 

<repository>  
      <snapshots>  
        <enabled>false</enabled>  
      </snapshots>  
      <id>central</id>  
      <name>Maven Repository Switchboard</name>  
      <url>http://repo1.maven.org/maven2</url>  
    </repository>  
mirror就是镜像,主要提供一个方便地切换远程仓库地址的途径。比如,上班的时候在公司,用电信的网络,连的是电信的仓库。回到家后,是网通的网络,我想连网通的仓库,就可以通过mirror配置,统一把我工程里的仓库地址都改成联通的,而不用到具体工程配置文件里一个一个地改地址。 

4、  ecplise中maven配置



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值