一、eclipse 新建maven 项目报错(因为没有配置maven环境)

1、问题:

① 出现的问题1:

Could not calculate build plan:Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

eclipse新建maven项目:


② 出现的问题2:

'Building' has encountered a problem. Errors occurred during the build.
eclipse新建maven项目:


2、分析问题:

① 错误原因:编译工具eclipse没有配置 maven的环境


3、解决:在eclipse中配置maven的环境

eclipse新建maven项目:


##### 3-1、又出现bug:

  • 报错信息如下:
Description Resource  Path  Location  Type
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 -> org.apache.maven.shared:maven-shared-incremental:jar:1.1 -> org.apache.maven:maven-core:jar:2.2.1 -> org.apache.maven:maven-profile:jar:2.2.1: ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-profile:jar:2.2.1: ArtifactResolutionException: org.apache.maven:maven-profile:pom:2.2.1 failed to transfer from http://maven.aliyun.com/nexus/content/groups/public during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of nexus-aliyun has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-profile:pom:2.2.1 from/to nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public): The operation was cancelled. pom.xml /ssm-xml-demo line 6 Maven Project Build Lifecycle Mapping Problem

eclipse新建maven项目:

eclipse新建maven项目:

eclipse新建maven项目:


3-1、解决:在eclipse中强制更新maven的项目:快捷键 alt+f5,然后勾选 Force Update of Snapshots/Releases

eclipse新建maven项目:


二、补充一下 maven的环境搭建


Maven 环境搭建

一、准备工作:

1、maven下载:官网:​​https://maven.apache.org/download.cgi​

  • 下载完成后解压出来

2、配置​​环境变量​​:

细节:为什么要单独配置一个M2_HOME 的变量:​​方便后续学习​

  • 后续使用的自动依赖的系统,比如SpringBoot、SpringCloud,它会引用M2_HOME 这个地址。

■ 添加系统变量:

□ M2_HOME maven目录下的bin目录

□ MAVEN_HOME maven的目录

□ 在系统的path中配置 %MAVEN_HOME%\bin

eclipse新建maven项目:eclipse新建maven项目:

■ 验证maven是否配置成功:查看maven版本的命令 mvn -version

eclipse新建maven项目:

3、修改maven 配置文件的镜像为 ​​阿里云镜像​

  • 配置文件位置:maven根目录/conf/settings.xml 找到镜像元素mirrors
  • 镜像:mirrors:
  • 作用:加速下载
  • 默认是使用国外的镜像,国内建议使用​​阿里云​​镜像加速下载


<mirror>
<id>nexus-aliyunid>
     <mirrorOf>*,!jeecg,!jeecg-snapshotsmirrorOf>
<name>Nexus aliyunname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
mirror>

<mirror>
<id>nexus-aliyunid>
     <mirrorOf>centralmirrorOf>
<name>Nexus aliyunname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
mirror>

4、修改maven 配置文件的​​本地仓库位置​

  • 修改本地仓库位置为:maven 根目录下 自己手动建立的 maven-repo
  • 配置文件位置:maven根目录/conf/settings.xml 找到 localRepository元素
<localRepository>E:\environment\mavenEvironment\apache-maven-3.8.2\maven-repolocalRepository>


作者:一乐乐​