精华内容
下载资源
问答
  • 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是什么

    二、Maven安装及配置

    1. Maven本地安装

    2. Maven环境变量的配置

    3. 修改maven配置文件

    三、idea中创建meven webapp及配置

    1. 配置 settings

     2. 创建 meven webapp


    一、Maven是什么

    1. Maven是Apache下的一个纯java开发的开源项目,它是一个项目管理工具,使用maven对java项目进行构建、依赖管理。

    2. 通俗的来说Maven就是一款帮助程序员构建项目的工具,我们只需要告诉Maven需要哪些Jar 包,它会帮助我们下载所有的Jar,极大提升开发效率

    Maven到底是什么?(参考链接)

    二、Maven安装及配置

    1. Maven本地安装

    apache官网下载(以目前最新的 3.6.1为例)

    右侧Download

    选择二进制的压缩包 

    下载完成后,解压到D盘(自己选择盘符,直接解压,建议不要再放在文件夹下面,点入即为根目录)

    这是我的路径  D:\apache-maven-3.6.1

    2. Maven环境变量的配置

    找到 Path 里添加 meven 的安装路径 D:\apache-maven-3.6.1

    添加 M2_HOME 变量 

    这样,电脑就知道你的meven在哪里了 

    然后打开 cmd,输入 mvn -v 

    出现 Maven home : D:\apache-maven-3.6.1  为成功

    3. 修改maven配置文件

    打开D盘刚才安装Maven的文件夹,找到conf目录下的settings文件

    maven会将从中央仓库下载的jar包放到本地仓库中,而这个本地仓库其实就是maven帮我们建立的一个文件夹,目录为C:\Users\你的用户名\.m2\repository,这个路径是可以修改的;我们修改到D盘

    本地仓库(.m2)

    运行原理
    运行Maven的时候,Maven所需要的任何构件都是直接从本地仓库获取的。如果本地仓库没有,它会首先尝试从远程仓库下载构件至本地仓库,然后再使用本地仓库的构件。

    Repository 仓库​​​​​​

    由于在配置时本地的仓库需要通过over wall下载 ,速度很慢,这里直接给大家放百度网盘链接,自行食用

    复制 D盘下config文件夹下的settings.xml 文件到 C盘用户 .m2 文件下 

      

     

    修改 .m2文件下的 settings 文件(D盘conf下的不用修改)

    为的是在使用 repository时,把下载的文件路径更改到你安装的 D:\repository  下

    .m2 的settings.xml修改如下

    <localRepository>D:\repository</localRepository>

    我们知道maven是从中央仓库下载jar包的,但是这个中央仓库的服务器是在国外的,下载会非常慢,好在阿里云做了一个国内的镜像仓库,所以我们还要把仓库的地址修改为阿里云的地址。

    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>

    https://maven.aliyun.com/mvn/guide 参考阿里云

    找到<mirros>标签,将上面的内容复制到里面即可。

    接下来修改maven项目的默认jdk版本,找到<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>
    

     

    配置好之后,然后输入 mvn help:system 

    下载资源(快慢取决于网速,文件很小。我下了半个小时,我哭辽^ -....)

    下载成功后会有 success  的提示 


    三、idea中创建meven webapp及配置

    1. 配置 settings

    在创建 meven项目时,由于导入的 jar包要在apache的官网上下载,速度特别慢(没错,我创建项目又用了半个小时),外网没办法....

    我们需要修改一下镜像文件,改为国内阿里爸爸的镜像(30分钟的事3分钟解决)

    打开 meven目录conf下的 settings

    ctrl + f 搜索 “<mirrors>”

    在<mirrors>标签里增加以下内容:

     <mirrors>
        <mirror>
        	<id>alimaven</id>
        	<name>aliyun maven</name>
        	<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        	<mirrorOf>*</mirrorOf>
        </mirror>
      </mirrors>

    再去下载maven依赖的时候,有些依赖包的地址已经变成了aliyun的地址了,速度比之前快了很多 

     2. 创建 meven webapp

    File----> New Project

    Next ----> 选择项目路径

    Finish 完成创建,联网后让idea自动生成配置文件

     

    创建完成

    Learn more Maven基础之项目管理构建

    展开全文
  • Maven安装配置

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

    一、安装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安装配置

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

    一、安装本地Maven

    tips: 官网为外网,下载速度较慢,这里提供3.6.3版本的三方链接下载Maven下载

    1. 无视下载速度以及需要其他版本的伙伴点此进入Maven官网下载

    2. 选择左侧Download
      在这里插入图片描述

    3. 点击箭头所指的链接进行下载
      在这里插入图片描述

    4. 下载完成后,选择一个路径进行解压

    5. 然后配置path环境变量,如图

    • 系统变量:MAVEN_HOME = F:\dev\apache-maven-3.6.1
    • 系统变量:path = %MAVEN_HOME%\bin
      MAVEN_HOME:
      在这里插入图片描述

    在这里插入图片描述

    path:
    在这里插入图片描述

    1. 然后win+R 运行cmd 输入 mvn -version,如图所示则配置成功

    在这里插入图片描述

    二、配置settings文件

    1. 在F:\dev\apache-maven-3.6.1\conf下可以找到settings文件,打开(嫌麻烦的直接看最后一步)

    2. 找到第52行,这里是maven默认的仓库
      在这里插入图片描述

    3. 我们复制第53行

    <localRepository>/path/to/local/repo</localRepository>
    

    将它拿到注释外并将中间的内容改成你需要的路径,如图

    <localRepository>F:/repository</localRepository>
    

    这里的路径随便设置,注意这里是正斜杠
    在这里插入图片描述

    1. 因为国外的服务器下载jar包很慢所以我们改为阿里云服务器(大约在150行左右),这两个仓库只用选一个(根据大家反馈建议使用第一个,第二个在有的版本可能会出现warning)
     <!-- 阿里云仓库 -->
            <mirror>
                <id>alimaven</id>
                <mirrorOf>central</mirrorOf>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
            </mirror>
         或者
          <mirror>
    		<id>nexus-aliyun</id>
    		<mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    	 </mirror>
    
    
    1. 如图,要夹在两个mirrors标签之间
      在这里插入图片描述

    2. 在最后配置jdk,也要夹在两个profiles标签之间(我这里使用的为jdk8)

    <!-- 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>
    
    

    在这里插入图片描述

    1. 配置完成,在命令行输入mvn help:system测试,看到下载链接里面是ailiyun的链接表示配置成功

    2. 嫌麻烦的直接复制配置文件的内容即可,不过路径还是要改(参考第3步)

    <?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>F:/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.
       |-->
      
        <!-- mirror
    	<mirrors>
         | 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>
    			<id>nexus-aliyun</id>
    			<mirrorOf>*</mirrorOf>
    			<name>Nexus aliyun</name>
    			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
    	</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.
       |
       |-->
        <!-- profile
    	<profiles>
         | 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>
    <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>
    </profiles>
    
    
    
      <!-- activeProfiles
       | List of profiles that are active for all builds.
       |
      <activeProfiles>
        <activeProfile>alwaysActiveProfile</activeProfile>
        <activeProfile>anotherAlwaysActiveProfile</activeProfile>
      </activeProfiles>
      -->
    </settings>
    
    
    
    展开全文
  • maven安装和详细配置 提示:下面是maven3.6.3版本百度云链接,记住maven3.3以上版本必须安装jdk1.7及以上版本,否则会出错。 链接:https://pan.baidu.com/s/1J0FNIBlF0JIm3QB9sIIlaA 提取码:4gud 文章目录maven...

    maven安装和详细配置

    提示:下面是maven3.6.3版本百度云链接,记住maven3.3以上版本必须安装jdk1.7及以上版本,否则会出错。
    链接:https://pan.baidu.com/s/1J0FNIBlF0JIm3QB9sIIlaA
    提取码:4gud



    前言

    提示:再次提醒,maven3.3+版本必须安装jdk1.7及以上版本,否则会出错的,maven可以直接通过上面链接下载,想要其他版本也可以到官网下载


    一、使用步骤

    1.安装maven

    安装如下(示例):
    在这里插入图片描述

    (1)、上面是我下载的maven-3.6.3版本,我下载在D盘,这个没要求,你可以直接下载到你想要放置的地方。
    (2)、右键安装包解压到当前文件夹就好了

    2.maven环境变量配置

    以win10为例(前两步就不贴图了,就是进入配置环境变量的界面,安装jdk的时候应该都会了):
    (1)、我的电脑(此电脑) 右键——属性。

    (2)、高级系统设置——环境变量。

    (3)、先点击新建系统变量(一定要看清楚是下面系统变量的新建)——变量名为MAVEN_HOME 变量值为maven的解压路径,注意是你自己的解压路径不是我的——点击确定。
    在这里插入图片描述

    (4)、找到path(记住是下面系统变量方框中的path)——编辑path变量——在弹出的框中点击新建—— %MAVEN_HOME%\bin——确定。
    在这里插入图片描述

    (5)、检验maven的配置情况:点击开始(或win10桌面左下脚任务栏的搜索框或者直接win+R)——在搜索框中输入cmd——回车
    在这里插入图片描述

    (6)、在提示命令行中输入mvn -version,回车,如图所示配置成功。
    在这里插入图片描述


    3.配置setting文件

    找到你maven的安装路径,进入conf文件夹,用编辑器打开setting.xml文件
    在这里插入图片描述

    1. 配置maven本地仓库
      maven本地仓库也可以不配置,如果不配置,默认本地仓库地址为C:\Users\Administrator\.m2\repository
      配置方法:我们直接找到52行,然后复制第53行代码,粘贴到注释外面(必须粘贴到注释外面,不然是无效代码),最后把<localRepository></localRepository>中间的路径修改成你自己创建的本地仓库路径就好了
    <localRepository>/path/to/local/repo</localRepository>
    

    下面是我的maven本地仓库路径:

    <localRepository>D:\Maven\repository</localRepository>
    

    在这里插入图片描述

    1. 配置maven阿里云镜像
      接下来我们需要配置maven镜像,如果我们不配置,我们下载jar包是从国外下载的,下载速度很慢,所以我们配置一下国内的阿里云镜像
      配置方法:找到未在注释标签内的mirrors,大约在145行左右,接着我们往mirrors标签内添加阿里云镜像,然后保存
    <mirror>
    	<id>alimaven</id>
    	<mirrorOf>central</mirrorOf>
    	<name>aliyun maven</name>
    	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
    

    在这里插入图片描述

    1. 配置maven全局jdk版本
      接下来我们可以为maven配置全局的jdk,这样我们在创建maven项目时就会自动使用该jdk版本,我配置的是jdk1.8
      配置方法:找到未在注释标签内的<profiles></profiles>,滑到最底部往上找很容易找到,然后在他们之中添加指定jdk代码,和配置阿里云镜像类似。
    <!-- 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>
    

    在这里插入图片描述



    总结

    以上就是maven的安装和详细配置了,下一篇博文——在Idea中创建maven项目。

    下一篇博文链接:https://blog.csdn.net/zzvar/article/details/114879815

    展开全文
  • eclipse+Maven安装和配置

    千次阅读 2017-05-23 11:01:07
    一、下载最新版的Maven,下载地址:http://maven.apache.org/download.cgi 二、将Maven下载到E:\maven...四、配置完成后,在命令行输入mvn -v,看到如下图说明安装成功 五、修改本地仓库  打开E:\maven\apach
  • maven安装配置(详细版)

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

    万次阅读 2017-05-03 14:23:06
    最近因为开始写一些集合框架的小项目,在看到一写博客的时候发现好多的人都是使用的maven创建的项目,其实开始学javaweb就应该使用maven来创建项目,先不说maven提供的项目管理上的好处,光是maven解决了jar包的依赖...
  • 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下载 maven下载地址,目前已经更新到3.6.3版本了,需要注意的是从maven3.3开始,jdk必须是1.7以上版本。 点击上图中红色链接下载到本地解压,目录如下图,目前博主所使用的Maven版本是...配置maven仓库...
  • Maven安装配置

    万次阅读 多人点赞 2018-08-13 14:14:58
    Maven安装配置以及使用IDEA配置创建Maven maven是什么  maven翻译为“专家”,“内行”。Maven是Apache下的一个纯java开发的开源项目,它是一个项目管理工具,使用maven对java项目进行构建、依赖管理。当前使用...
  • MAC maven 安装和配置

    万次阅读 2017-04-07 09:39:23
    maven编译后代码安装下载地址:http://maven.apache.org/download.cgi 选择 Binary tar.gz archivemkdir ~/.java cd ~/.java wget ...
  • 非常详细的Maven安装配置教程

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

    千次阅读 2018-12-04 11:02:36
    一、需要准备的东西 1. JDK 2. Eclipse 3. Maven程序包 二、下载与安装 1. 前往https://maven.apache.org/download.cgi下载最新版的Maven安装包: ...下载完成后解压到你想存放...2.配置环境: 新建环境变量MAVE...
  • Linux下JDK和Maven安装配置

    千次阅读 2018-06-29 11:24:31
    本文Java安装采用windows下载后上传至...一、安装rz/sz命令:sudo yum install lrzsz -y二、Java安装配置:1.下载要安装的jdk,官网链接:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-download...
  • Maven安装配置详解(Win10)

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

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

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

    千次阅读 2019-10-18 11:11:51
    1.下载maven安装包(选择maven版本时需要与jdk版本...2.解压安装包到指定目录(maven是免安装类型,将压缩包解压之后进行环境变量配置安装好了) 在终端中输入命令:tar xzvf /srv/ftp/apache-maven-3.6.2-bin...
  • 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-10-20 16:55:38
    这次大家分享下MAC电脑中maven安装配置。 #正文 ##1、下载Maven maven地址 ##2、maven 解压到安装目录 ##3、打开终端,输入vim ~/.bash_profile,编辑bash_profile 文件 ##4、输入下面文本,保存,退出 ...
  • Maven 的下载安装和配置

    万次阅读 多人点赞 2019-06-26 11:39:04
    1、进入官网下载,并解压。...3、测试是否安装成功 输入 mvn -v出现以下相关的信息就表示成功了。 4、配置本地仓库 1、先新创建一个新的文件夹作为maven的仓库。maven-repository。 2、修...
  • IDEA中Maven安装配置(详细教程)

    千次阅读 2019-08-19 20:26:36
    1.下载IntelliJ IDEA软件 下载Community社区版即可 这里对下载安装Idea不做介绍 2.Java环境的搭建 安装JDK 配置环境变量(不做介绍) 3.Maven的下载与解压 ...4.Maven环境变量的配置 打开环境变量的配置 ...
  • 带你了解Maven,并搞定安装和配置

    万次阅读 多人点赞 2020-02-19 00:09:07
    Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),用来运行定义在生命周期...
  • maven安装+maven本地仓库配置

    千次阅读 2018-05-15 15:04:40
    安装maven前我们电脑上要确保安装了JDK1.6以上的版本我本机的java版本是1.7.0_01的版本然后去官网上下载maven,我本地的maven版本是maven-3.1.1maven官网下载地址是 http://maven.apache.org/download.html...
  • maven3.8.1安装配置流程

    千次阅读 2021-07-23 15:30:45
    maven3.8.1安装配置流程 1、解压apache-maven-3.8.1-bin.zip到指定目录 我这里是解压到:C:\sofeware\tools\mvn\apache-maven-3.8.1 2、配置环境变量 右击此电脑–>选择属性–>高级系统设置–>选择右...
  • 二、配置Maven 三、配置Maven本地仓库。 一、官网下载Maven 链接地址:http://maven.apache.org/download.cgi 找到Dowload,如图: 下载完成后,解压压缩包,解压的路径记住,结构如下: 二、配置Maven ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 505,384
精华内容 202,153
关键字:

maven安装和配置