maven3.8.1安装及配置流程

maven3.8.1安装及配置流程

1、解压apache-maven-3.8.1-bin.zip到指定目录
  • 我这里是解压到:C:\sofeware\tools\mvn\apache-maven-3.8.1
2、配置环境变量
  • 右击此电脑–>选择属性–>高级系统设置–>选择右下角的环境变量–>选择系统变量

    –>新建MAVEN_HOME变量值就是你的maven的解压目录我这里是:C:\sofeware\tools\mvn\apache-maven-3.8.1–>找到path增加一条环境变量:%MAVEN_HOME%\bin–>保存退出;
    在这里插入图片描述

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UbDGdIVo-1627025443746)(C:\文档\md_photo\1625454103492.png)]

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7DXNoXVZ-1627025443751)(C:\文档\md_photo\1625454155681.png)]

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vrVfhWAS-1627025443758)(C:\文档\md_photo\1625454198834.png)]

3、win+r输入cmd 双击打开cmd输入mvn -v会输出以下结果

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-beIkcadQ-1627025443765)(C:\文档\md_photo\1625453924348.png)]

4、settings的配置

  • setting 文件在apache-maven-3.8.1\conf里边我的setting文件的位置是C:\sofeware\tools\mvn\apache-maven-3.8.1\conf,在修改setting文件之前需要保留副本,避免配置出错无法恢复之前的版本
<?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>
  -->
  <!--本地maven仓库地址-->
  <localRepository>C:\sofeware\tools\mvn\Respository</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.
   |确定maven在执行构建时是否应尝试连接到网络。
	|这将对工件下载、工件部署等产生影响。
   | Default: false
  <offline>false</offline>
  -->
<offline>ture</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.
   |	它的工作原理是这样的:POM可以声明一个用于解析某些工件的存储库。但是,此存储库有时可能会遇到流量过大的问题,因此人们已将其镜像到多个地方。
   | 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.
   |	该存储库定义将具有唯一的id,因此我们可以为该存储库创建镜像引用,用作备用下载站点。镜像站点将是该存储库的首选服务器。
   |-->
  <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.
     |	指定要使用的存储库镜像站点,而不是给定的存储库。
	 |  此镜像服务的存储库的ID与此镜像的mirrorOf元素匹配。ID用于继承和直接查找,并且在镜像集中必须是唯一的。
    <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>https://maven.aliyun.com/repository/central</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.
   |	这是一个概要文件列表,可以以多种方式激活,并且可以修改构建过程。
   |    在settings.xml中提供的概要文件旨在提供本地机器特定的路径和存储库位置,这些路径和位置允许构建在本地环境中工作。
   | 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.
   |	例如,如果您有一个集成测试插件(如cactus),
   |    它需要知道Tomcat实例的安装位置,那么您可以在这里提供一个变量,以便在构建过程中取消对该变量的引用以配置cactus插件。
   | 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.
   |	如上所述,配置文件可以通过多种方式激活。
   |   其中一种方法——本文档的activeProfiles部分(settings.xml)——将在后面讨论。
   |   另一种方法本质上依赖于系统属性的检测,或者匹配属性的特定值,或者仅仅测试其存在性。
   |	配置文件也可以由JDK version prefix激活,其中值为“1.4”的配置文件可能会在JDK版本“1.4.2\u 07”上执行生成时激活配置文件。
   |    最后,可以直接从命令行指定活动概要文件的列表。
   | 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.
   |	对于在settings.xml中定义的概要文件,您只能指定工件存储库、插件存储库和自由格式属性作为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.
     |	指定要使用上述一个或多个机制激活的生成过程的一组介绍。
	 |	出于继承目的,要通过<activatedProfiles/>或命令行激活配置文件,配置文件必须具有唯一的ID。
     | 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.
     |	配置文件标识的一个受鼓励的最佳实践是对配置文件使用一致的命名约定,
	 |		例如“env dev”、“env test”、“env production”、“user jdcasey”、“user brett”等。
	 |	这将使您更直观地了解引入的配置文件集试图完成的任务,尤其是当您只有一个用于调试的配置文件id列表时。
     | 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>
    -->
      <!-- 这一段必须加上-->
		<profile>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <name>createdbymyself</name>
                    <url>http://maven.oschina.net/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <name>createdbymyself</name>
                    <url>http://maven.oschina.net/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
		
		<!--jdk配置-->
		<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>
    <!--
     | 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>

ance


–>


  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 要安装 Maven 3.8.1,您需要遵循以下步骤: 1. 首先,您需要在 Maven 的官方网站(https://maven.apache.org/)上下载 Maven 的最新版本(3.8.1)的二进制文件。 2. 下载完成后,解压缩下载文件。您可以选择将解压缩的文件保存在任何您喜欢的位置。 3. 一旦解压缩完成,打开计算机的终端(命令提示符)。 4. 设置环境变量:在终端中输入 `export M2_HOME=<maven解压文件的路径>`,然后按Enter键。例:`export M2_HOME=/usr/local/apache-maven-3.8.1` 5. 接下来,将 Maven 的 `bin` 目录添加到系统的 `PATH` 系统变量中。在终端中输入 `export PATH=$PATH:$M2_HOME/bin`,然后按Enter键。 6. 检查 Maven 是否已成功安装。在终端中输入 `mvn -version`,然后按Enter键。如果成功安装,您将看到 Maven 的版本信息打印出来。 7. 现在,您可以使用 Maven 3.8.1 创建和构建项目了。在终端中导航到您的项目目录,然后输入 Maven 相关的命令来构建、测试、打包等。 希望以上步骤可以帮助您成功安装 Maven 3.8.1。如果遇到任何问题,请参考 Maven 的官方文档或在社区寻求帮助。 ### 回答2: 安装Maven 3.8.1是一个简单的过程,你只需要按照以下步骤进行操作。 首先,你需要下载Maven安装包。你可以在Maven的官方网站(https://maven.apache.org/download.cgi)上找到最新版本的安装包。请选择合适的安装包,通常你需要选择一个二进制zip文件。 下载完成后,将zip文件解压到你想要安装的目录。你可以选择一个合适的目录,如C:\Maven,并将zip文件解压到该目录。 接下来,你需要设置Maven的环境变量。打开控制面板并点击系统和安全,然后点击系统。在系统窗口下,点击左侧的高级系统设置。在系统属性窗口中,点击“环境变量”按钮。在系统变量部分,找到“Path”变量并点击“编辑”按钮。在编辑环境变量窗口中,点击“新建”按钮并输入Maven的bin目录的路径(例如:C:\Maven\bin)。点击“确定”并关闭所有窗口。 最后,你需要验证Maven是否已正确安装。打开命令提示符,并输入“mvn -version”命令。如果你看到了Maven的版本信息,则表明安装已成功。 现在,你已经成功地安装Maven 3.8.1。你可以使用Maven来构建和管理你的Java项目。希望这些信息对你有所帮助。 ### 回答3: Maven是一个开源的项目管理和构建工具,用于帮助开发团队管理Java项目的开发、构建和部署。Maven 3.8.1是Maven的最新版本,下面是安装Maven 3.8.1的步骤: 第一步,下载Maven 3.8.1的安装包。可以在Maven官方网站(https://maven.apache.org/download.cgi)上找到最新版本的安装包。 第二步,解压安装包。将下载的安装包解压到一个合适的目录中,例如C:\Program Files\Apache Maven。 第三步,设置环境变量。将Maven的bin目录添加到系统的PATH环境变量中,以便在任意目录下都可以使用Maven命令。可以通过以下步骤完成: - 右键点击“我的电脑”,选择“属性”; - 点击“高级系统设置”; - 在系统属性对话框中,点击“环境变量”按钮; - 在系统变量列表中,找到名为“Path”的变量,并将Maven的bin目录添加到变量值的末尾,例如“C:\Program Files\Apache Maven\bin”; - 点击“确定”按钮保存设置。 第四步,验证安装。打开命令行界面,输入“mvn -version”命令,如果能正确显示Maven的版本号,说明安装成功。 安装完成后,可以通过编辑Maven配置文件,对Maven的默认行为进行一些自定义。Maven配置文件位于安装目录下的conf文件夹中的settings.xml文件。 以上就是Maven 3.8.1的安装过程,希望对你有帮助!
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值