您的位置:首页 > 业界新闻

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

2018-03-05 15:34 861 查看
后台服务工具maven:maven安装配置1、  maven下载下载地址:https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz2、  解压配置全局变量用工具进行解压。全局变量:/etc/profile用户变量:~/.bash_profile   export M3=/Users/heimabb/Documents/maven/apache-maven-3.3.9export PATH=$PATH:$M3/bin验证:命令:mvn -versionApache Maven 3.3.9(bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)Maven home:/Users/heimabb/Documents/maven/apache-maven-3.3.93、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配置



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: