分享程序网
首页
  • java
微服务
微前端
环境搭建
数据库
设计模式
算法
软件
解决问题
链接
首页
  • java
微服务
微前端
环境搭建
数据库
设计模式
算法
软件
解决问题
链接
  • java

    • JDK
    • JVM
    • JAVA优化

maven

下载

http://maven.apache.org/download.cgi

下载好之后可以选择放在D盘下,解压。

配置

解压完之后找到setting.xml配置文件,修改配置,该文件在解压目录的conf文件夹下。例如在D盘下解压,文件位置在:

D:\apache-maven-3.6.3\conf

打开setting配置文件后,可以修改以下几项,如果你喜欢把配置写在pom.xml文件中的话,你也可以不做任何修改:

  1. 找到localRepository标签,修改为:
<localRepository>D:\maven\maven-repositroy</localRepository>

因为windows系统默认将下载的所有依赖包放在C盘下

  1. 如果公司是在内网环境下,需要使用代理才能访问外网,需要找到proxies标签,设置如下:

    <proxies>
       <proxy>
    		<id>optional</id>
    		<active>true</active>
    		<protocol>http</protocol>
    		<username>proxyuser</username><!-- 代理账户 -->
    		<password>proxypass</password><!-- 代理密码 -->
    		<host>172.16.0.1</host><!-- 代理IP -->
    		<port>3128</port><!-- 代理端口 -->
    		<nonProxyHosts>10.187.144.11</nonProxyHosts><!-- 忽略IP -->
        </proxy>
      </proxies>
    
  2. 如果需要打包上传使用deploy命令的话,需要找到servers标签,设置如下:

    <servers>
        <server>
          <id>test</id> <!-- 镜像id,例如alimaven -->
          <username>root</username> <!-- nexus用户名 -->
          <password>root</password> <!-- nexus密码 -->
        </server>
      </servers>
    
  3. 如果需要使用其他镜像库的话,需要找到mirrors标签,设置如下:

    <mirrors>
    	<mirror>
    		<id>alimaven</id>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    		<mirrorOf>central</mirrorOf>       
    	</mirror>
        <mirror>
            <id>nexus</id>
            <name>nexus</name>
            <mirrorOf>self-maven</mirrorOf>
            <url>http://127.0.0.1:8081/nexus/content/repositories/dts-maven/</url>
        </mirror>
      </mirrors>
    
  4. 然后找到profiles标签做一些配置:

    <profiles>
    	<profile>
          <id>jdk-1.8</id>
          <activation>
    		<activeByDefault>true</activeByDefault>
    		<jdk>1.8</jdk>
          </activation>
          <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
          </properties>
        </profile>
    	<profile>
          <id>alimaven</id> 
          <repositories>
            <repository>
              <id>alimaven</id> 
              <url>http://maven.aliyun.com/nexus/content/groups/public/</url> 
              <releases>
                <enabled>true</enabled>
              </releases> 
              <snapshots>
                <enabled>true</enabled> 
                <updatePolicy>always</updatePolicy>
              </snapshots>
            </repository>
          </repositories>
        </profile>
      </profiles>
      <activeProfiles>
        <activeProfile>alimaven</activeProfile>
      </activeProfiles>
    
Last Updated:
Contributors: chengli