Intellij IDEA安装Maven(非常详细)

安装Maven

安装路径:点击链接进去直接下载所需的版本Maven官网
http://maven.apache.org/download.cgi

最新版本下载方式

1、点击链接进入Maven官网
2、找到左侧栏的Download找到Files下载即可

二、所有版本的下载方式(里面新老版本都有)
1、点击链接进入Maven官网
2、找到左侧栏的Download
3、查看图二中箭头所指向的archives点击进去里面有所有的版本
4、找到需要的版本号进行对应下载

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

环境变量设置

找到系统变量的方式:
3、 此电脑 —>右击找到属性—>右击选中高级系统设置—>系统属性下找到环境变量进行配置系统变量
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
输入命令 mvn -v说明成功(要在绝对路径下)
在这里插入图片描述
四、配置setting.xml文件
1、在E:LearnMavenapache-maven-3.5.4conf下可以找到settings文件

2、找到第55行,这里是maven默认的仓库(在解压的路径下面去添加一个空的repo文件)
在这里插入图片描述
3、55行设置的repo路径之后变成默认选中这个路径、
在这里插入图片描述
4、因为国外的服务器下载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>

5、如何所示操作,需要放在mirrors中间,不可随意乱放
在这里插入图片描述
最后配置jdk,也要夹在两个profiles标签之间(我这里使用的为jdk8)
在这里插入图片描述
总的如下:

<?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>E:LearnMavenapache-maven-3.5.4
epo</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>
	
  </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>
    -->
	
	<!-- 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>
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

在这里插入图片描述
然后还有最后一个问题,默认创建maven项目是下载网络上的一个文件archetype-catalog.xml,该文件的大小有5-6M,下载的速度很慢,导致创建过程也变得很慢。所以我们需要配置一下。当然,这里解决的方法有三种,这里我选择最容易的一种,就是修改maven的VM Options参数配置。
-DarchetypeCatalog=internal
在这里插入图片描述

测试Maven

回到主界面,点击New Project,然后我们创建一个maven项目
在这里插入图片描述
在这里插入图片描述

有阿里云连接说明成功
在这里插入图片描述

  • 8
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 1. 首先,确保已经安装Maven,并且已经配置好了环境变量。 2. 打开IntelliJ IDEA,点击File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven。 3. 在Maven的配置页面中,点击“+”按钮,添加Maven安装路径。 4. 点击“Apply”按钮,保存配置。 5. 在IntelliJ IDEA的项目中,右键点击pom.xml文件,选择“Add as Maven Project”。 6. 等待IntelliJ IDEA自动下载Maven依赖。 7. 配置Maven的运行参数,例如JVM参数、Maven命令等。 8. 点击“Run”按钮,运行Maven命令。 9. 查看Maven的输出结果,确保项目构建成功。 以上就是IntelliJ IDEA配置Maven的步骤,希望能对你有所帮助。 ### 回答2: IntelliJ IDEA 是一款非常出色的 Java 开发工具,它不仅可以满足 Java 开发的各种需求,还支持多种框架,如 Spring,Hibernate 等,并且还支持 Maven 项目。 在进行 Maven 项目开发时,配置 Maven 是非常重要的一个环节,下面就是关于 IntelliJ IDEA 配置 Maven详细步骤: 首先,确保你已经安装Java SDK 和 Maven,并将它们配置好了环境变量。 然后,在 IntelliJ IDEA 中,打开菜单栏的 File -> Settings 在打开的 Settings 界面中,找到左侧的 Maven 选项,点击进入。 然后,点击右侧的 Add 按钮,添加一个 Maven Repository。 接着,在弹出的窗口中输入 Repository Name 和 Repository URL,这里以 Maven Centeral 仓库为例,输入完后,点击 OK 保存。 然后,点击左侧的 Maven -> Importing,勾选上 Automatically download 勾选框,并设置本地仓库的路径,大多数情况下,使用默认路径即可。 接着,点击左侧的 Maven -> Runner,在右侧的 Runner 下方,可以看到 Maven Home Directory,确保它的值与你本地 Maven 的目录一致。 最后,点击 OK,完成 Maven 的配置。 同时,如果你要创建一个新的 Maven 项目,可以选择 File -> New -> Project,然后选择 Maven 项目类型,接着按照向导进行操作即可。 总之,通过以上步骤,你就可以在 IntelliJ IDEA 中顺利配置和使用 Maven 了。 ### 回答3: IntelliJ IDEA是一款优秀的Java开发工具,在使用该工具进行Java开发时,常常需要使用到Maven作为依赖管理工具。下面是如何在IntelliJ IDEA中配置Maven详细流程: 第一步,安装Maven插件。 在IntelliJ IDEA中,选择File -> Settings,在弹出的窗口中选择Plugins,然后在右侧的搜索框中输入"Maven"。在搜索结果中找到"Maven Integration"插件并安装。 第二步,创建Maven项目。 在IntelliJ IDEA中,选择File -> New -> Project,然后在弹出的窗口中选择"Maven"。接着在创建Maven项目的设置中填写相关信息,例如Project Name、Group Name、Artifact Name等等。点击“Next”进行下一步。 第三步,配置Maven环境。 在IntelliJ IDEA中,选择File -> Settings,在弹出的窗口中选择Build, Execution, Deployment -> Build Tools -> Maven。在右侧的选项卡中,设置Maven安装路径和配置文件路径(settings.xml)。 第四步,设置Maven项目配置。 在IntelliJ IDEA中,选择File -> Project Structure,在弹出的窗口中选择"Modules",然后选择Maven项目名称。接着在"Dependencies"选项卡中,可以添加Maven依赖项。 以上四个步骤完成后,您就可以在IntelliJ IDEA中愉快地进行Maven项目的开发了。当我们需要添加新的Maven依赖项的时候,可以直接在pom.xml文件中添加相应的依赖项即可。 总之,IntelliJ IDEA是一款功能强大的Java开发工具,而Maven作为一个流行的依赖管理工具,与IntelliJ IDEA无缝衔接,能够更好地帮助Java开发者进行开发工作,提高开发效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值