idea 自带的 maven download plugins 太慢了

idea 自带的 maven download plugins 太慢了
在这里插入图片描述

自带的maven会随着IDEA的升级而升级,可能会出现各种意料之外的问题,所以我这里建议新手还是不要用自带的Maven,因为自带的Maven会被IDEA屏蔽很多细节,导致新手对于Maven不够了解。

鼠标右键IDEA软件图标,点击打开所在文件夹,进入D:\IntelliJ IDEA 2019.3.1\plugins\maven\lib\maven3\conf目录,打开settings.xml文件并进行如下编辑。大家可以根据我的截图中的行数来配置。

下载 maven

参考:
maven的下载安装配置教程(详细图文)
https://blog.youkuaiyun.com/weixin_43836369/article/details/116330044

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

https://dlcdn.apache.org/maven/

设置环境变量:

MAVEN_HOME
C:\apache-maven-3.3.9-bin\apache-maven-3.3.9\

PATH添加
;%MAVEN_HOME%\bin;

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
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.home}/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>E:\anzhuang\code</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>
      <id>nexus-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
	
	<server>
      <id>nexus-snapshots</id>
      <username>admin</username>
      <password>admin123</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>     
       <id>nexus-releases</id>     
       <mirrorOf>*</mirrorOf>     
       <url>http://192.168.99.219:8088/nexus/content/groups/public</url>     
    </mirror>    
     <mirror>     
       <id>nexus-snapshots</id>     
       <mirrorOf>*</mirrorOf>     
      <url>http://192.168.99.219:8088/nexus/content/groups/public-snapshots</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>    
       <id>nexus</id>    
       <repositories>    
         <repository>    
           <id>nexus-releases</id>    
           <url>http://192.168.99.219:8088/nexus/content/groups/public</url>    
           <releases><enabled>true</enabled></releases>    
           <snapshots><enabled>true</enabled></snapshots>    
         </repository>    
         <repository>    
           <id>nexus-snapshots</id>    
           <url>http://192.168.99.219:8088/nexus/content/groups/public-snapshots</url>    
           <releases><enabled>true</enabled></releases>    
           <snapshots><enabled>true</enabled></snapshots>    
         </repository>    
       </repositories>    
       <pluginRepositories>    
          <pluginRepository>    
                 <id>nexus-releases</id>    
                  <url>http://192.168.99.219:8088/nexus/content/groups/public</url>    
                  <releases><enabled>true</enabled></releases>    
                  <snapshots><enabled>true</enabled></snapshots>    
                </pluginRepository>    
                <pluginRepository>    
                  <id>nexus-snapshots</id>    
                   <url>http://192.168.99.219:8088/nexus/content/groups/public-snapshots</url>    
                 <releases><enabled>true</enabled></releases>    
                  <snapshots><enabled>true</enabled></snapshots>    
              </pluginRepository>    
          </pluginRepositories>    
     </profile>    
  </profiles>


  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

C:/apache-maven-3.3.9-bin/apache-maven-3.3.9
C:\Users\UserName.m2\settings.xml
E:\anzhuang\code

初试:idea file ->Invalidate Caches /Restsrts

      或者 工具右侧栏Maven Reimport

      或者 Maven命令: mvn clean compile

再者:

1.项目目录:mvn idea:module

2.idea->build/rebuild module

<think>我们正在处理一个关于IntelliJ IDEAMaven项目的问题:用户打开一个旧的Maven项目,pom.xml中的plugins部分出现了红色下划线。这通常表示Maven在解析这些插件时遇到了问题,可能是由于依赖下载失败、版本不兼容或配置错误等原因。 根据提供的引用,我们可以总结以下几点可能的解决方案: 1. 尝试使用Maven的clean和install命令(引用[1])。 2. 如果plugins有红色下划线,可以尝试点击“Reload All Maven Projects”(引用[1])。 3. 切换Maven版本(引用[2]中提到从3.9.1切换到3.6.1解决了问题)。 4. 配置国内镜像仓库(如阿里云镜像,引用[3]和引用[5])。 5. 检查网络连接,确保能够访问Maven仓库。 6. 检查pom.xml中插件的版本是否可用,或者是否存在版本冲突。 此外,我们还可以考虑: 7. 检查IDEAMaven的配置(如Maven home path、User settings file等)是否正确。 8. 删除本地仓库中对应的依赖,然后重新下载(有时候本地仓库的依赖可能损坏)。 步骤建议: 1. 首先,尝试重新加载Maven项目:在IDEA右侧的Maven面板中,点击刷新按钮(Reload All Maven Projects)。 2. 如果问题仍然存在,尝试执行clean和install:在Maven面板中,先执行clean,再执行install。 3. 检查Maven配置:确保使用的是正确的Maven版本和设置文件(特别是settings.xml中配置了镜像仓库)。 4. 切换Maven版本:如果当前使用的是较新的Maven版本(如3.9.x),可以尝试切换到较稳定的版本(如3.6.3或3.8.6)。 5. 检查网络和仓库:确保网络正常,并且镜像仓库配置正确(如阿里云镜像)。 6. 如果以上步骤无效,可以尝试删除本地仓库中相关插件的目录(位于用户目录下的.m2/repository),然后重新加载项目。 另外,注意引用[5]中提到的IDEA乱码问题,虽然不直接相关,但如果控制台输出乱码可能导致错误信息难以识别,所以确保IDEA的编码设置正确(如File Encoding设置为UTF-8)。 根据引用[4]和[5],我们还应该注意IDEA的自动导入设置,确保在pom.xml更改后自动导入依赖。但这里的问题可能是首次导入失败,所以自动导入可能已经失效。 具体操作步骤: 步骤1:重新加载Maven项目 -IDEA右侧找到Maven面板(通常是一个“M”图标),点击面板上的刷新按钮(Reload All Maven Projects)。 步骤2:执行Maven命令 -Maven面板中,展开项目的生命周期(Lifecycle),先双击clean,再双击install。观察控制台输出,看是否有下载失败或错误信息。 步骤3:检查Maven配置 - 打开IDEA的设置(Settings),搜索Maven,检查以下配置: - Maven home path: 确保指向正确的Maven安装目录。 - User settings file: 确保使用的是正确的settings.xml文件,并且该文件中配置了镜像仓库(如阿里云)。 - Local repository: 确保本地仓库路径正确。 步骤4:切换Maven版本 - 如果当前Maven版本较新,可以尝试下载一个旧版本(如3.6.3),然后在IDEAMaven设置中切换到这个旧版本。 步骤5:检查镜像仓库配置 - 打开Maven的settings.xml文件(在conf目录下或用户目录下的.m2目录中),确保配置了镜像仓库。例如: ```xml <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/central</url> </mirror> ``` 步骤6:删除本地仓库中的相关依赖 - 关闭IDEA,删除本地仓库中对应插件的目录(例如,如果插件groupId是org.apache.maven.plugins,则删除该目录),然后重新打开IDEA并重新加载项目。 步骤7:检查pom.xml文件 - 检查pom.xml中声明的插件版本是否在Maven仓库中存在。如果该版本已经不存在或者被移除,需要更新版本号。 如果以上步骤都不能解决问题,可能需要查看具体的错误信息(在Maven控制台输出中),根据错误信息进一步排查。 相关问题: 1. 如何配置IntelliJ IDEA中的Maven仓库镜像? 2. 如何在IntelliJ IDEA中切换Maven版本? 3. Maven项目中的依赖下载失败有哪些常见原因? 4. 如何解决Maven插件版本不兼容的问题? 5. 在IntelliJ IDEA中,如何重新下载所有Maven依赖?</think>### IntelliJ IDEA 打开旧 Maven 项目时 Plugins 出现红色下划线的解决方法 此问题通常由 **依赖解析失败** 或 **配置不兼容** 引起。以下是逐步解决方案: --- #### 步骤 1:强制重新加载 Maven 依赖 1. 打开 IDEA 右侧 **Maven 面板**(工具栏右侧 "M" 图标) 2. 点击 **刷新按钮** 🔄(Reload All Maven Projects) 3. 若仍报错,尝试 **清理缓存**: - 顶部菜单 → **File → Invalidate Caches... → Invalidate and Restart** --- #### 步骤 2:检查 Maven 仓库配置 红色下划线常因仓库访问失败导致。需配置国内镜像: 1. 打开 Maven 配置文件: `IDEA安装目录/plugins/maven/lib/maven3/conf/settings.xml` 2. 添加阿里云镜像(引用[3][5]): ```xml <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> ``` 3. 在 IDEA 中重新加载配置: **Settings → Build → Maven → User settings file** → 确认路径正确 --- #### 步骤 3:切换 Maven 版本 旧项目可能不兼容新版 Maven(引用[2]): 1. 下载稳定版 Maven(如 3.6.x)[官网下载](https://maven.apache.org/download.cgi) 2. 在 IDEA 中切换: **Settings → Build → MavenMaven home path** → 选择解压目录 > ✅ 推荐使用 **3.6.3**(兼容性最佳) --- #### 步骤 4:执行 Maven 生命周期命令 1. 在 Maven 面板中依次执行: - 右键项目 → **Run Maven → clean** - 右键项目 → **Run Maven → install** 2. 观察控制台输出: - 成功标志:输出 `BUILD SUCCESS`(引用[1]) - 失败时需检查错误日志中的具体依赖名 --- #### 步骤 5:检查插件兼容性 若特定插件报红: 1. 打开 `pom.xml`,检查插件版本: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <!-- 检查此处版本 --> </plugin> </plugins> </build> ``` 2. 访问 [Maven Central](https://mvnrepository.com/) 确认版本是否存在 3. 旧项目可尝试 **降级插件版本**(如改用 2.x 或 3.5.x) --- #### 其他注意事项 - **JDK 版本**:确保 `pom.xml` 中 `<java.version>` 与项目 SDK 一致 - **网络代理**:若使用公司代理,需在 **Settings → Appearance → System Settings → HTTP Proxy** 中配置 - **本地仓库重置**:删除 `~/.m2/repository` 目录后重新加载(强制全量下载) > 💡 经验提示:多数红色下划线问题通过 **步骤2(镜像配置)+ 步骤3(降级Maven)** 解决(引用[2][5])。 --- ### 相关问题 1. Maven 依赖下载失败时如何快速定位问题源? 2. 如何为 IntelliJ IDEA 配置全局的 Maven 仓库镜像? 3. 旧版 Maven 项目迁移到新环境需要注意哪些兼容性问题? 4. 除了阿里云,还有哪些国内可用的 Maven 镜像仓库? 5. 如何解决 Maven 插件版本与 JDK 版本不匹配的问题? [^1]: 第八步,选择 IDEA 右侧 Maven 面板,点击 clean 再点击 install... [^2]: 切换maven仓库时,maven生命周期plugins红色下划线报错... [^3]: 本人的目录为:D:\WORK\DEVELOP\IntelliJ IDEA 2018.3.4\plugins\maven\lib\maven3\conf... [^5]: idea_home/plugins/maven/lib/maven3/conf/setting.xml...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值