当前位置 : 主页 > 编程语言 > 其它开发 >

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

来源:互联网 收集:自由互联 发布时间:2022-05-21
一、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 reso

一、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

image


② 出现的问题2:

'Building' has encountered a problem. Errors occurred during the build.
image



2、分析问题: ① 错误原因:编译工具eclipse没有配置 maven的环境



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

image


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

image

image

image


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

image





二、补充一下 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

image-20220323174612772 image-20220323174737503 ■ 验证maven是否配置成功:查看maven版本的命令 mvn -version image-20220323175147905 3、修改maven 配置文件的镜像为 阿里云镜像
  • 配置文件位置:maven根目录/conf/settings.xml 找到镜像元素mirrors

  • 镜像:mirrors:

    • 作用:加速下载
    • 默认是使用国外的镜像,国内建议使用阿里云镜像加速下载
       <!-- 添加之前,先把原来的镜像全注释掉 -->
      <!-- 配置方式1 -->
       <mirror>
            <id>nexus-aliyun</id>
         <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
    
  <!-- 配置方式2 -->
	<mirror>
        <id>nexus-aliyun</id>
     <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
4、修改maven 配置文件的本地仓库位置
  • 修改本地仓库位置为:maven 根目录下 自己手动建立的 maven-repo
  • 配置文件位置:maven根目录/conf/settings.xml 找到 localRepository元素
  <localRepository>E:\environment\mavenEvironment\apache-maven-3.8.2\maven-repo</localRepository>

上一篇:网关中间件
下一篇:没有了
网友评论