• Maven的安装及修改为阿里云下载依赖


    使用JAVA工程管理越来越多的jar包,担心导错了,多导了,漏导了怎么办?

    换一个IDE项目后项目会不会出一堆BUG,看的头皮发麻?

    自己写的代码放在别人的机器上运行会不会出问题?

    Maven的强大毋庸置疑,当使用Maven后以上这些都不是问题,但是配置maven是一件耐心的事情,基本步骤总结如下:

    一、下载
    http://maven.apache.org/download.cgi
    也可以直接在eclipse工具中下载,点击eclipse菜单栏Help->Eclipse Marketplace搜索关键字maven到插件Maven Integration for Eclipse 并点击安装即可


    架构Maven工作环境(配置环境变量)
    新建:MAVEN_HOME
    路径(例如):D:360Downloads oolsmarven3.5apache-maven-3.5.0
    添加到path配置文件中:;%MAVEN_HOME%in;
    二、配置好后验证
    输入mvn -version
    成功后会有如以下提示:

    Microsoft Windows [版本 6.1.7601]
    版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

    C:UsersAdministrator>mvn -version
    Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:0
    6+08:00)
    Maven home: D:360Downloads oolsmarven3.5apache-maven-3.5.0-binapache-maven-
    3.5.0in..
    Java version: 1.8.0_121, vendor: Oracle Corporation
    Java home: D:Program FilesJavajdk1.8.0_121jre
    Default locale: zh_CN, platform encoding: GBK
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"


    三、修改默认下载地址,默认下载地址在C盘中如下:

    C:UsersAdministrator.m2
    建议换一个地址,防止系统变慢,重装系统也不会影响。
    如:D:eee1701javaee_2maveninport_aliyun.m2

    四、将安装路径下的apache-maven-3.5.0confsettings.xml文件复制一份到新地址的.m2目录下面(与repository在同一目录)。


    五、打开eclipse将Maven工程添加到eclipse工具中。
    window->preferences->maven->installations->add->maven安装路径。

    六、打开settings.xml,修改如下2个地方的内容:
    1、此处为存放下载依赖存放地方,在文件第53行:

    原始文件:
    <!-- localRepository
    | The path to the local repository maven will use to store artifacts.
    |
    | Default: ${user.home}/.m2/repository
    <localRepository>/path/to/local/repo</localRepository>
    -->
    修改后的文件:
    <!-- localRepository
    | The path to the local repository maven will use to store artifacts.
    |
    | Default: ${user.home}/.m2/repository
    <localRepository>/path/to/local/repo</localRepository>
    -->
    <localRepository>D:eee1701javaee_2maveninport_aliyun.m2 epository</localRepository>

    2、此处为修改为从阿里云服务器上下载依赖,强烈建议更换,下载速度会快很多,在文件第160行

    原始文件:
    <mirrors>
    <!-- mirror
    | Specifies a repository mirror site to use instead of a given repository. The repository that
    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
    |
    <mirror>
    <id>mirrorId</id>
    <mirrorOf>repositoryId</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://my.repository.com/repo/path</url>
    </mirror>
    -->
    </mirrors>

    修改后的文件:
    <mirrors>
    <!-- mirror
    | Specifies a repository mirror site to use instead of a given repository. The repository that
    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
    |
    <mirror>
    <id>mirrorId</id>
    <mirrorOf>repositoryId</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://my.repository.com/repo/path</url>
    </mirror>
    -->

    <!-- 阿里云镜像 下载配置 -->
    <mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>

    <!-- 另一个备用模板 -->

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



    </mirrors>

    完成后重启eclipse.

  • 相关阅读:
    Docker Compose实例
    Jenkins远程执行shell出现java: command not found
    SpringBoot之导入导出Excel
    在Jenkins中配置执行远程shell命令
    XJar: Spring-Boot JAR 包加/解密工具,避免源码泄露以及反编译
    Elasticsearch集成ik分词器
    AAAAAA
    Logstash-安装logstash-filter-multiline插件(解决logstash匹配多行日志)
    Elastic Kibana文档
    failed to create rwlayer: lstat /var/lib/docker/overlay2/ no such file or directory
  • 原文地址:https://www.cnblogs.com/lq147760524/p/6906025.html
Copyright © 2020-2023  润新知