精华内容
下载资源
问答
  • Maven安装与配置

    万次阅读 多人点赞 2021-04-20 22:38:12
    安装Maven 官网下载maven Binary是可执行版本,已经编译好可以直接使用。 Source是源代码版本,需要自己编译成可执行软件才可使用。 tar.gz和zip两种压缩格式,其实这两个压缩文件里面包含的内容是同样的,只是...

    一、安装Maven

    1. 官网下载maven

    Binary是可执行版本,已经编译好可以直接使用。
    Source是源代码版本,需要自己编译成可执行软件才可使用。

    tar.gz和zip两种压缩格式,其实这两个压缩文件里面包含的内容是同样的,只是压缩格式不同
    tar.gz格式的文件比zip文件小很多,用于unix操作系统。
    zip格式用于Windows操作系统,但在Windows系统使用WinRar工具一样能够解压缩tar.gz格式

    1. 下载完成后,解压到某一路径下。本文以E:\Tools\Maven\apache-maven-3.8.1为例,实际配置环境变量时以自己安装的路径为准

    二、配置环境变量

    1. 右键此电脑–>属性–>高级系统设置–>环境变量
    2. 新建变量MAVEN_HOME = E:\Tools\Maven\apache-maven-3.8.1(以自己的安装路径为准)
    3. 编辑变量Path,添加变量值%MAVEN_HOME%\bin
    4. 然后win+R运行cmd,输入mvn -version,如图所示则配置成功

    三、配置本地仓库

    1. 在E:\Tools\Maven\路径下新建maven-repository文件夹,用作maven的本地库。
      在这里插入图片描述

    2. 在路径E:\Tools\Maven\apache-maven-3.8.1\conf下找到settings.xml文件

    3. 找到节点localRepository,在注释外添加

    <localRepository>E:\Tools\Maven\maven-repository</localRepository>
    

    在这里插入图片描述

    localRepository节点用于配置本地仓库,本地仓库其实起到了一个缓存的作用,它的默认地址是 C:\Users\用户名.m2。
    当我们从maven中获取jar包的时候,maven首先会在本地仓库中查找,如果本地仓库有则返回;如果没有则从远程仓库中获取包,并在本地库中保存。
    此外,我们在maven项目中运行mvn install,项目将会自动打包并安装到本地仓库中。

    四、配置镜像

    1. 在settings.xml配置文件中找到mirrors节点
    2. 添加如下配置(注意要添加在<mirrors>和</mirrors>两个标签之间,其它配置同理)
    <!-- 阿里云仓库 -->
    <mirror>
    	<id>alimaven</id>
    	<mirrorOf>central</mirrorOf>
    	<name>aliyun maven</name>
    	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
    

    在这里插入图片描述

    因为国外的服务器下载jar包很慢所以我们改为阿里云服务器

    虽然mirrors可以配置多个子节点,但是它只会使用其中的一个节点,即默认情况下配置多个mirror的情况下,只有第一个生效,只有当前一个mirror无法连接的时候,才会去找后一个;而我们想要的效果是:当a.jar在第一个mirror中不存在的时候,maven会去第二个mirror中查询下载,但是maven不会这样做!

    五、配置JDK

    1. 在settings.xml配置文件中找到profiles节点
    2. 添加如下配置
    <!-- java版本 --> 
    <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>
    

    在这里插入图片描述


    配置完成,win+R运行cmd,输入mvn help:system测试,配置成功则本地仓库(E:\Tools\Maven\maven-repository)中会出现一些文件
    在这里插入图片描述

    首次执行 mvn help:system 命令,Maven相关工具自动帮我们到Maven中央仓库下载缺省的或者Maven中央仓库更新的各种配置文件和类库(jar包)到Maven本地仓库中。
    下载完各种文件后, mvn help:system 命令会打印出所有的Java系统属性和环境变量,这些信息对我们日常的编程工作很有帮助。

    若需要IDEA配置Maven,请参考 https://blog.csdn.net/qq_38190185/article/details/115943152?spm=1001.2014.3001.5501

    附录

    完整的settings.xml配置文件,可以直接复制使用,只需要修改相应的路径即可

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
    
    <!--
     | This is the configuration file for Maven. It can be specified at two levels:
     |
     |  1. User Level. This settings.xml file provides configuration for a single user,
     |                 and is normally provided in ${user.home}/.m2/settings.xml.
     |
     |                 NOTE: This location can be overridden with the CLI option:
     |
     |                 -s /path/to/user/settings.xml
     |
     |  2. Global Level. This settings.xml file provides configuration for all Maven
     |                 users on a machine (assuming they're all using the same Maven
     |                 installation). It's normally provided in
     |                 ${maven.conf}/settings.xml.
     |
     |                 NOTE: This location can be overridden with the CLI option:
     |
     |                 -gs /path/to/global/settings.xml
     |
     | The sections in this sample file are intended to give you a running start at
     | getting the most out of your Maven installation. Where appropriate, the default
     | values (values used when the setting is not specified) are provided.
     |
     |-->
    <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
      <!-- 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>E:\Tools\Maven\maven-repository</localRepository>
      <!-- interactiveMode
       | This will determine whether maven prompts you when it needs input. If set to false,
       | maven will use a sensible default value, perhaps based on some other setting, for
       | the parameter in question.
       |
       | Default: true
      <interactiveMode>true</interactiveMode>
      -->
    
      <!-- offline
       | Determines whether maven should attempt to connect to the network when executing a build.
       | This will have an effect on artifact downloads, artifact deployment, and others.
       |
       | Default: false
      <offline>false</offline>
      -->
    
      <!-- pluginGroups
       | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
       | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
       | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
       |-->
      <pluginGroups>
        <!-- pluginGroup
         | Specifies a further group identifier to use for plugin lookup.
        <pluginGroup>com.your.plugins</pluginGroup>
        -->
      </pluginGroups>
    
      <!-- proxies
       | This is a list of proxies which can be used on this machine to connect to the network.
       | Unless otherwise specified (by system property or command-line switch), the first proxy
       | specification in this list marked as active will be used.
       |-->
      <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
      </proxies>
    
      <!-- servers
       | This is a list of authentication profiles, keyed by the server-id used within the system.
       | Authentication profiles can be used whenever maven must make a connection to a remote server.
       |-->
      <servers>
        <!-- server
         | Specifies the authentication information to use when connecting to a particular server, identified by
         | a unique name within the system (referred to by the 'id' attribute below).
         |
         | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
         |       used together.
         |
        <server>
          <id>deploymentRepo</id>
          <username>repouser</username>
          <password>repopwd</password>
        </server>
        -->
    
        <!-- Another sample, using keys to authenticate.
        <server>
          <id>siteServer</id>
          <privateKey>/path/to/private/key</privateKey>
          <passphrase>optional; leave empty if not used.</passphrase>
        </server>
        -->
      </servers>
    
      <!-- mirrors
       | This is a list of mirrors to be used in downloading artifacts from remote repositories.
       |
       | It works like this: a POM may declare a repository to use in resolving certain artifacts.
       | However, this repository may have problems with heavy traffic at times, so people have mirrored
       | it to several places.
       |
       | That repository definition will have a unique id, so we can create a mirror reference for that
       | repository, to be used as an alternate download site. The mirror site will be the preferred
       | server for that repository.
       |-->
      <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>alimaven</id>
    		<mirrorOf>central</mirrorOf>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    	</mirror>
    	
        <mirror>
          <id>maven-default-http-blocker</id>
          <mirrorOf>external:http:*</mirrorOf>
          <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
          <url>http://0.0.0.0/</url>
          <blocked>true</blocked>
        </mirror>
      </mirrors>
    
      <!-- profiles
       | This is a list of profiles which can be activated in a variety of ways, and which can modify
       | the build process. Profiles provided in the settings.xml are intended to provide local machine-
       | specific paths and repository locations which allow the build to work in the local environment.
       |
       | For example, if you have an integration testing plugin - like cactus - that needs to know where
       | your Tomcat instance is installed, you can provide a variable here such that the variable is
       | dereferenced during the build process to configure the cactus plugin.
       |
       | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
       | section of this document (settings.xml) - will be discussed later. Another way essentially
       | relies on the detection of a system property, either matching a particular value for the property,
       | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
       | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
       | Finally, the list of active profiles can be specified directly from the command line.
       |
       | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
       |       repositories, plugin repositories, and free-form properties to be used as configuration
       |       variables for plugins in the POM.
       |
       |-->
      <profiles>
      
    	<!-- java版本 --> 
    	<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
         | Specifies a set of introductions to the build process, to be activated using one or more of the
         | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
         | or the command line, profiles have to have an ID that is unique.
         |
         | An encouraged best practice for profile identification is to use a consistent naming convention
         | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
         | This will make it more intuitive to understand what the set of introduced profiles is attempting
         | to accomplish, particularly when you only have a list of profile id's for debug.
         |
         | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
        <profile>
          <id>jdk-1.4</id>
    
          <activation>
            <jdk>1.4</jdk>
          </activation>
    
          <repositories>
            <repository>
              <id>jdk14</id>
              <name>Repository for JDK 1.4 builds</name>
              <url>http://www.myhost.com/maven/jdk14</url>
              <layout>default</layout>
              <snapshotPolicy>always</snapshotPolicy>
            </repository>
          </repositories>
        </profile>
    
        -->
    
        <!--
         | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
         | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
         | might hypothetically look like:
         |
         | ...
         | <plugin>
         |   <groupId>org.myco.myplugins</groupId>
         |   <artifactId>myplugin</artifactId>
         |
         |   <configuration>
         |     <tomcatLocation>${tomcatPath}</tomcatLocation>
         |   </configuration>
         | </plugin>
         | ...
         |
         | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
         |       anything, you could just leave off the <value/> inside the activation-property.
         |
        <profile>
          <id>env-dev</id>
    
          <activation>
            <property>
              <name>target-env</name>
              <value>dev</value>
            </property>
          </activation>
    
          <properties>
            <tomcatPath>/path/to/tomcat/instance</tomcatPath>
          </properties>
        </profile>
        -->
      </profiles>
    
      <!-- activeProfiles
       | List of profiles that are active for all builds.
       |
      <activeProfiles>
        <activeProfile>alwaysActiveProfile</activeProfile>
        <activeProfile>anotherAlwaysActiveProfile</activeProfile>
      </activeProfiles>
      -->
    </settings>
    

    References

    https://blog.csdn.net/a805814077/article/details/100545928
    https://blog.csdn.net/github_37759996/article/details/90748461
    https://www.cnblogs.com/Lints/p/11163073.html

    展开全文
  • maven安装与配置IDEA,最新教程

    千次阅读 2020-10-13 17:45:46
    打开 Windows 的CDM,输入java-version验证,如果你还没安装jdk环境,要先去安排配置 jdk 环境 2. Maven 下载 下载地址:https://maven.apache.org/ 系统 包名 Windows apache-maven-3.3.9-bin.zip ...

    Maven环境配置

    1. 先配置好 jdk环境

    打开 Windows 的CDM,输入java-version验证,如果你还没安装jdk环境,要先去安排配置 jdk 环境
    image-20201013172148604

    2. Maven 下载

    下载地址:https://maven.apache.org/

    image-20201013172148604

    image-20201013172148604

    系统包名
    Windowsapache-maven-3.3.9-bin.zip
    Linuxapache-maven-3.3.9-bin.tar.gz
    Macapache-maven-3.3.9-bin.tar.gz

    3. 解压Maven安装包

    把刚刚下载的Maven安装包解压到想要的安装的路径下,我这里把安装包解压到 D:\IT\apache-maven-3.5.4(我这里是用以前下载的安装包的),复制bin的路径,等一下配置环境用到image-20201013172148604

    4. 设置下载源和本地仓库路径

    打开Maven解压路径,在conf里面打开settings.xml

    • 设置本地仓库地址,添加**D:/IT/apache-maven-3.5.4/usrlibs**,路径要根据自己的填D:/IT/apache-maven-3.5.4/usrlibs

    image-20201013172148604

    • 由于Maven 默认是从国外的中央仓库下载依赖的,而我们访问国外的网站的时候,国内有防火墙,添加国内的中央仓库,下载依赖速度会更快

    找到 在中间添加已下内容

      <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>alimaven</id>
    		<mirrorOf>central</mirrorOf>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    	</mirror>
    
    	<!-- 中央仓库1 -->
    	<mirror>
    		<id>repo1</id>
    		<mirrorOf>central</mirrorOf>
    		<name>Human Readable Name for this Mirror.</name>
    		<url>http://repo1.maven.org/maven2/</url>
    	</mirror>
    
    	<!-- 中央仓库2 -->
    	<mirror>
    		<id>repo2</id>
    		<mirrorOf>central</mirrorOf>
    		<name>Human Readable Name for this Mirror.</name>
    		<url>http://repo2.maven.org/maven2/</url>
    	</mirror>
      </mirrors>
      
    

    image-20201013172148604

    5. 设置Maven环境变量

    右键 “计算机”,选择 “属性”,之后点击 “高级系统设置”,点击"环境变量",来设置环境变量,有以下系统变量需要配置:

    由于Maven2后的新版本我们不用配置 MAVEN_HOME,或者M2_HOME,这里我们配置Path就可以了

    点击编辑 Path,添加变量的值

    image-20201013172148604

    配置好后一路按确定就可以了

    image-20201013172148604

    最后打开CDM输入:mvn -version ,验证配置是否成功

    image-20201013172148604

    6. 配置 IDEA

    IDEA 默认是使用自动的Maven的

    image-20201013172148604

    设置这两项

    • Maven home directory: 找到刚刚我们解压的Maven 路径就可以了

    • Local repository: 点击配置解压的Maven 路径下的conf里面的settings.xml

    image-20201013172148604
    okkk…啦

    展开全文
  • 非常详细的Maven安装与配置教程

    万次阅读 多人点赞 2019-07-12 12:33:11
    Maven安装与配置1. 下载Maven2. 解压压缩包3. 添加 M2_HOME 和 MAVEN_HOME4. 添加到环境变量 - PATH路径下5. 验证Maven是否成功安装6. 修改本地仓库位置7. 添加Maven阿里云仓库 1. 下载Maven 访问 Maven官方网站 ...

    1. 下载Maven

    访问 Maven官方网站 http://maven.apache.org/download.cgi
    找到以下链接并下载在这里插入图片描述

    2. 解压压缩包

    下载 Maven 的 zip 文件,例如: apache-maven-3.6.1-bin.zip,将它解压到你要安装 Maven 的文件夹。
    此时我解压的路径在 D:\developer_tools\下
    在这里插入图片描述

    3. 添加 M2_HOME 和 MAVEN_HOME

    添加 M2_HOME 和 MAVEN_HOME 环境变量到 Windows 环境变量,并将其指向你的 Maven 文件夹。
    在这里插入图片描述

    4. 添加到环境变量 - PATH路径下

    添加 Maven bin 文件夹到 PATH 的最后,如: %M2_HOME%\bin; 这样就可以在命令中的任何目录下运行 Maven 命令了
    在这里插入图片描述

    5. 验证Maven是否成功安装

    执行 mvn –version 在命令提示符下,如下图输出结果:

    C:\Users\Wu Hao>mvn -version Apache Maven 3.6.1
    (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
    Maven home: D:\developer_tools\apache-maven-3.6.1\bin… Java version:
    1.8.0_212, vendor: Oracle Corporation, runtime: D:\developer_tools\Java\jdk1.8.0_212\jre Default locale: zh_CN,
    platform encoding: GBK OS name: “windows 10”, version: “10.0”, arch:
    “amd64”, family: “windows”

    则成功安装Maven

    6. 修改本地仓库位置

    每个用户在自己的用户目录下都有一个路径名为 .m2/respository/ 的仓库目录。

    Maven 本地仓库默认被创建在 %USER_HOME% 目录下。要修改默认位置,在 %M2_HOME%\conf 目录中的 Maven 的 settings.xml 文件中定义另一个路径。

    <localRepository>D:\developer_tools\RepMaven</localRepository>
    

    配置位置如图所示:
    在这里插入图片描述

    7. 添加Maven阿里云仓库,设置jdk版本为1.8

    Maven 仓库默认在国外, 国内使用难免很慢,我们可以更换为阿里云的仓库。

    1. 修改 maven 根目录下的 conf 文件夹中的 setting.xml 文件,在 mirrors 节点上
    <mirrors>
        <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>        
        </mirror>
    </mirrors>
    

    在这里插入图片描述
    2. 在 conf 文件夹setting.xml中的 <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> 
    
    1. 项目的pom.xml文件里添加
    <repositories>  
    	<repository>  
    	    <id>alimaven</id>  
    	    <name>aliyun maven</name>  
    	    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
    	    <releases>  
    	        <enabled>true</enabled>  
    	    </releases>  
    	    <snapshots>  
    	        <enabled>false</enabled>  
    	    </snapshots>  
    	</repository>  
    </repositories>
    

    8. 在IDEA中修改Maven的地址

    将如图所示地址修改成个人的安装目录即可。
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    9. 附录: setting.xml文件作为参考

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
    
    <!--
     | This is the configuration file for Maven. It can be specified at two levels:
     |
     |  1. User Level. This settings.xml file provides configuration for a single user,
     |                 and is normally provided in ${user.home}/.m2/settings.xml.
     |
     |                 NOTE: This location can be overridden with the CLI option:
     |
     |                 -s /path/to/user/settings.xml
     |
     |  2. Global Level. This settings.xml file provides configuration for all Maven
     |                 users on a machine (assuming they're all using the same Maven
     |                 installation). It's normally provided in
     |                 ${maven.conf}/settings.xml.
     |
     |                 NOTE: This location can be overridden with the CLI option:
     |
     |                 -gs /path/to/global/settings.xml
     |
     | The sections in this sample file are intended to give you a running start at
     | getting the most out of your Maven installation. Where appropriate, the default
     | values (values used when the setting is not specified) are provided.
     |
     |-->
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <!-- 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:\developer_tools\RepMaven</localRepository>
    
      <!-- interactiveMode
       | This will determine whether maven prompts you when it needs input. If set to false,
       | maven will use a sensible default value, perhaps based on some other setting, for
       | the parameter in question.
       |
       | Default: true
      <interactiveMode>true</interactiveMode>
      -->
    
      <!-- offline
       | Determines whether maven should attempt to connect to the network when executing a build.
       | This will have an effect on artifact downloads, artifact deployment, and others.
       |
       | Default: false
      <offline>false</offline>
      -->
    
      <!-- pluginGroups
       | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
       | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
       | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
       |-->
      <pluginGroups>
        <!-- pluginGroup
         | Specifies a further group identifier to use for plugin lookup.
        <pluginGroup>com.your.plugins</pluginGroup>
        -->
    	<pluginGroup>com.spotify</pluginGroup>
      </pluginGroups>
    
      <!-- proxies
       | This is a list of proxies which can be used on this machine to connect to the network.
       | Unless otherwise specified (by system property or command-line switch), the first proxy
       | specification in this list marked as active will be used.
       |-->
      <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
      </proxies>
    
      <!-- servers
       | This is a list of authentication profiles, keyed by the server-id used within the system.
       | Authentication profiles can be used whenever maven must make a connection to a remote server.
       |-->
      <servers>
        <!-- server
         | Specifies the authentication information to use when connecting to a particular server, identified by
         | a unique name within the system (referred to by the 'id' attribute below).
         |
         | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
         |       used together.
         |
        <server>
          <id>deploymentRepo</id>
          <username>repouser</username>
          <password>repopwd</password>
        </server>
        -->
    
        <!-- Another sample, using keys to authenticate.
        <server>
          <id>siteServer</id>
          <privateKey>/path/to/private/key</privateKey>
          <passphrase>optional; leave empty if not used.</passphrase>
        </server>
        -->
      </servers>
    
      <!-- mirrors
       | This is a list of mirrors to be used in downloading artifacts from remote repositories.
       |
       | It works like this: a POM may declare a repository to use in resolving certain artifacts.
       | However, this repository may have problems with heavy traffic at times, so people have mirrored
       | it to several places.
       |
       | That repository definition will have a unique id, so we can create a mirror reference for that
       | repository, to be used as an alternate download site. The mirror site will be the preferred
       | server for that repository.
       |-->
      <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>alimaven</id>
    		  <name>aliyun maven</name>
    		  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    		  <mirrorOf>central</mirrorOf>        
    		</mirror>
      </mirrors>
    
      <!-- profiles
       | This is a list of profiles which can be activated in a variety of ways, and which can modify
       | the build process. Profiles provided in the settings.xml are intended to provide local machine-
       | specific paths and repository locations which allow the build to work in the local environment.
       |
       | For example, if you have an integration testing plugin - like cactus - that needs to know where
       | your Tomcat instance is installed, you can provide a variable here such that the variable is
       | dereferenced during the build process to configure the cactus plugin.
       |
       | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
       | section of this document (settings.xml) - will be discussed later. Another way essentially
       | relies on the detection of a system property, either matching a particular value for the property,
       | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
       | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
       | Finally, the list of active profiles can be specified directly from the command line.
       |
       | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
       |       repositories, plugin repositories, and free-form properties to be used as configuration
       |       variables for plugins in the POM.
       |
       |-->
      <profiles>
        <!-- profile
         | Specifies a set of introductions to the build process, to be activated using one or more of the
         | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
         | or the command line, profiles have to have an ID that is unique.
         |
         | An encouraged best practice for profile identification is to use a consistent naming convention
         | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
         | This will make it more intuitive to understand what the set of introduced profiles is attempting
         | to accomplish, particularly when you only have a list of profile id's for debug.
         |
         | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
        <profile>
          <id>jdk-1.4</id>
    
          <activation>
            <jdk>1.4</jdk>
          </activation>
    
          <repositories>
            <repository>
              <id>jdk14</id>
              <name>Repository for JDK 1.4 builds</name>
              <url>http://www.myhost.com/maven/jdk14</url>
              <layout>default</layout>
              <snapshotPolicy>always</snapshotPolicy>
            </repository>
          </repositories>
        </profile>
        -->
    
        <!--
         | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
         | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
         | might hypothetically look like:
         |
         | ...
         | <plugin>
         |   <groupId>org.myco.myplugins</groupId>
         |   <artifactId>myplugin</artifactId>
         |
         |   <configuration>
         |     <tomcatLocation>${tomcatPath}</tomcatLocation>
         |   </configuration>
         | </plugin>
         | ...
         |
         | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
         |       anything, you could just leave off the <value/> inside the activation-property.
         |
        <profile>
          <id>env-dev</id>
    
          <activation>
            <property>
              <name>target-env</name>
              <value>dev</value>
            </property>
          </activation>
    
          <properties>
            <tomcatPath>/path/to/tomcat/instance</tomcatPath>
          </properties>
        </profile>
        -->
        <profile>
          <id>jdk1.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>
      </profiles>
    
      <!-- activeProfiles
       | List of profiles that are active for all builds.
       |
      <activeProfiles>
        <activeProfile>alwaysActiveProfile</activeProfile>
        <activeProfile>anotherAlwaysActiveProfile</activeProfile>
      </activeProfiles>
      -->
      <activeProfiles>
        <activeProfile>jdk1.8</activeProfile>
      </activeProfiles>
    </settings>
    
    
    展开全文
  • Win10 Maven安装与配置

    千次阅读 2018-09-27 15:19:05
    Win10 Maven安装与配置 文章目录Win10 `Maven`安装与配置1、准备工作2、安装3、配置`Maven`本地仓库4、后续操作 1、准备工作 检查JDK是否安装 java -version 如果没有安装JDK,请先安装 下载Maven...

    1、准备工作

    • 检查JDK是否安装
    java -version
    

    如果没有安装JDK,请先安装

    2、安装

    • 将安装包解压到D:\目录下
      在这里插入图片描述

    • 新建环境变量,变量名:MAVEN_HOME,变量值:D:\apache-maven-3.5.4[Maven根目录]
      在这里插入图片描述

    • 编辑环境变量Path,新增%MAVEN_HOME%\bin\
      在这里插入图片描述

    • 通过mvn -v命令在Dos命令行检查是否安装成功
      在这里插入图片描述
      至此,我们已经安装成功

    3、修改Maven本地

    3.1、修改远程中央仓库

    说明
    我们用Maven的时候,因为Maven自带的远程中央仓库在国外,所以经常会很慢。我们可以把远程中央仓库改为国内阿里的远程仓库。

    • 打开D:\apache-maven-3.5.4\conf\settings.xml文件修改内容
      在这里插入图片描述
      将上图红框中代码修改为如下
    <mirror> 
          //该镜像的id 
          <id>nexus-aliyun</id> 
          //该镜像用来取代的远程仓库,central是中央仓库的id 
          <mirrorOf>central</mirrorOf> 
          <name>Nexus aliyun</name> 
          //该镜像的仓库地址,这里是用的阿里的仓库 
          <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
    

    3.2、修改本地仓库

    • D:\apache-maven-3.5.4新建maven-repository文件夹,作为Maven的本地仓库
    • 打开D:\apache-maven-3.5.4\conf\settings.xml文件,找到如下代码并替换
    <localRepository>/path/to/local/repo</localRepository>
    # 替换为
    <localRepository>D:\apache-maven-3.5.4\maven-repository</localRepository>
    

    说明

    • localRepository节点默认是被注释掉的,需要把它移到注释之外,然后将localRepository节点的值改为本地的Maven仓库路径即可。
    • localRepository节点用于配置本地仓库,本地仓库其实起到了一个缓存的作用,它的默认地址是 C:\Users\用户名.m2
    • 当我们从maven中获取jar包的时候,maven首先会在本地仓库中查找,如果本地仓库有则返回;如果没有则从远程仓库中获取包,并在本地库中保存
    • 此外,我们在maven项目中运行mvn install命令,项目将会自动打包并安装到本地仓库中

    4、后续操作

    • Dos命令行执行mvn help:system命令,配置没有问题会在本地Maven仓库出现一些文件
      在这里插入图片描述
      Maven安装配置已经完成,可以利用Maven命令在Dos命令行新建项目了
    展开全文
  • Maven安装与配置详解(Win10)

    万次阅读 多人点赞 2018-07-26 18:49:49
    下载与安装Maven 1.前往 http://maven.apache.org/download.cgi 下载最新版的Maven程序 2.可将该压缩包解压到一个自己创建的 Apache 文件夹里,以后自己用到 Apache 系列的程序可都放在此目录。 3....
  • Maven安装与配置完整教程

    千次阅读 2018-12-04 11:02:36
    二、下载与安装 1. 前往https://maven.apache.org/download.cgi下载最新版的Maven安装包: 下载后缀zip的文件。下载完成后解压到你想存放的位置,我的位置是:D:\Java\NewMaven,版本是3.22的,不是最新的 2....
  • Maven安装配置及在idea中配置

    万次阅读 多人点赞 2019-07-31 10:16:54
    二、Maven安装配置 1. Maven本地安装 2. Maven环境变量的配置 3. Maven 配置repository 三、idea中创建meven webapp及配置 1. 配置 settings 2. 创建 meven webapp 一、Maven是什么 1. Maven是Apache下的...
  • Maven安装与配置

    万次阅读 多人点赞 2019-09-04 19:48:17
    Maven超详细的安装与配置步骤
  • window maven安装与配置

    千次阅读 2018-08-13 16:13:19
    二、下载与安装 1. 前往https://maven.apache.org/download.cgi下载最新版的Maven程序: 2. 将文件解压到D:\Program Files\Apache\maven目录下: 3. 新建环境变量MAVEN_HOME,赋值D:\Program Files\Ap...
  • linux下安装与配置maven

    千次阅读 2019-10-18 11:11:51
    1.下载maven安装包(选择maven版本时需要jdk版本...2.解压安装包到指定目录(maven是免安装类型,将压缩包解压之后进行环境变量配置安装好了) 在终端中输入命令:tar xzvf /srv/ftp/apache-maven-3.6.2-bin...
  • idea+maven安装与配置

    千次阅读 2021-01-14 10:57:09
    环境:Java1.8(此博客默认已安装配置好Java环境,如未配置请先配置Java环境) 版本信息: idea2019.1.3 maven3.6.0 Idea 首先可从官网下载idea对应版本的idea安装包(社区版是免费的但是功能受限,旗舰版功能完整...
  • Maven安装与配置及IDEA的设置

    千次阅读 2020-02-27 16:45:58
    一、下载安装Maven配置环境变量 1.Maven下载地址访问https://maven.apache.org/download.cgi,下载最新的Maven安装包 我现在的是版本 apache-maven-3.6.1,如下图: 解压并安装路径(参考:F:\idea\maven): ...
  • maven安装配置(详细版)

    万次阅读 多人点赞 2020-08-26 11:33:40
    1.下载: 方式一可以从官方下载,下载页面:...3.配置MAVEN_HOME maven 的使用是在jdk的基础上,所以电脑必须有jdk 第一步:新增环境变量:MAVEN_HOME 第二步:在path环境变量中添加:%MAVEN_HOME%\bin
  • maven3 安装与配置

    千次阅读 2019-07-20 18:27:07
    转载自:...安装 Maven 之前要求先确定你的 JDK 已经安装配置完成。Maven是 Apache 下的一个项目,目前最新版本是 3.0.4,我用的也是这个。 首先去官网下载 Maven:ht...
  • Maven安装与配置,整合Eclipse

    万次阅读 2017-04-12 18:40:49
    Maven安装与配置,整合Eclipse
  • 【MAC日常使用】— MAVEN安装配置

    千次阅读 2018-10-20 16:55:38
    这次和大家分享下MAC电脑中maven安装配置。 #正文 ##1、下载Maven maven地址 ##2、maven 解压到安装目录 ##3、打开终端,输入vim ~/.bash_profile,编辑bash_profile 文件 ##4、输入下面文本,保存,退出 ...
  • Maven安装配置

    万次阅读 多人点赞 2018-08-13 14:14:58
    Maven安装配置以及使用IDEA配置创建Maven maven是什么  maven翻译为“专家”,“内行”。Maven是Apache下的一个纯java开发的开源项目,它是一个项目管理工具,使用maven对java项目进行构建、依赖管理。当前使用...
  • 概述 Maven是Apache基金组织的一...安装与配置 安装 第一步:下载镜像 apache镜像(我下载的是3.3.9) 第二步:解压缩 我的解压缩目录是E:\LOMTOM_STU\ecplise\apache-maven-3.3.9 第四步:测试 打开cmd,输入mvn ...
  • Maven3.6.1安装配置

    千次阅读 多人点赞 2020-09-13 03:29:03
    1.下载 ...打开 apache-maven-3.6.1\conf\settings.xml 配置本地仓库 <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.hom.
  • mac下maven安装配置与使用

    万次阅读 多人点赞 2018-05-13 00:15:19
    本文主要包括的几个部分:1.maven下载 2.maven安装与配置 3.eclipse中配置maven 4.eclipse的maven插件安装 5.eclipse中使用maven创建web项目。(本文已经默认你已经安装与配置好jdk环境,如果没有配置好请参考这篇...
  • Maven下载安装与配置IDEA

    千次阅读 2018-12-27 11:23:10
    Maven下载安装与配置IDEA一、下载安装二、配置本地仓库三、配置阿里云镜像下载四、IDEA配置Maven 一、下载安装 前往 https://maven.apache.org/download.cgi 下载最新版的Maven程序。 将文件解压到D:\...
  • Maven安装与环境配置(Windows)

    万次阅读 2016-05-24 10:12:51
    注意:Maven3以上版本要求安装jdk1.7...、解压安装包3、配置Maven环境变量配置M2_HOME环境变量,指向maven安装目录,并将bin目录追加到PATH路径中,方便在命令行调用。Windows:Linux:在/etc/profile文件中添加Maven
  • Linux 安装Maven与配置

    万次阅读 2018-01-05 15:50:39
    Apache Maven,是一个软件(特别是Java软件)项目管理及自动构建工具,由Apache软件基金会所提供。基于项目对象模型(缩写:POM)概念,Maven利用一个中央信息...下面说明如何安装配置Maven。 下载压缩包 wget ...
  • maven安装与zsh环境变量配置

    千次阅读 2018-09-18 09:46:58
    title: maven安装与zsh环境变量配置 tags: maven环境变量, zsh环境变量 grammar_cjkRuby: true 1、官网下载maven文件 maven download 按照安装提示进行操作,先解压,然后配置环境变量: Installing Apache Maven ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 504,755
精华内容 201,902
关键字:

maven安装与配置