如何使用Eclipse创建一个Maven项目?

2026-05-05 21:191阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1040个文字,预计阅读时间需要5分钟。

如何使用Eclipse创建一个Maven项目?

1. 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

解决方法:

1.确保已经安装了 Maven 环境。

2.检查 Eclipse 的 Maven 配置,确保 Maven 安装路径正确。

3.在 Eclipse 中,通过菜单Window -> Preferences -> Maven -> Installations 查看已安装的 Maven 安装。

4.如果没有安装,需要下载 Maven 安装包,并按照提示进行安装。

5.安装完成后,重启 Eclipse,问题应该能够解决。


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


② 出现的问题2:

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



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



3、解决:在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 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 (maven.aliyun.com/nexus/content/groups/public): The operation was cancelled. pom.xml /ssm-xml-demo line 6 Maven Project Build Lifecycle Mapping Problem


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





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



Maven 环境搭建 一、准备工作: 1、maven下载:官网:maven.apache.org/download.cgi
  • 下载完成后解压出来
2、配置环境变量
  • 细节:为什么要单独配置一个M2_HOME 的变量:方便后续学习
    • 后续使用的自动依赖的系统,比如SpringBoot、SpringCloud,它会引用M2_HOME 这个地址。
■ 添加系统变量:

□ M2_HOME maven目录下的bin目录

□ MAVEN_HOME maven的目录

如何使用Eclipse创建一个Maven项目?

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

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

  • 镜像:mirrors:

    • 作用:加速下载
    • 默认是使用国外的镜像,国内建议使用阿里云镜像加速下载

    <!-- 添加之前,先把原来的镜像全注释掉 --> <!-- 配置方式1 --> <mirror> <id>nexus-aliyun</id>      <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf> <name>Nexus aliyun</name> <url>maven.aliyun.com/nexus/content/groups/public</url> </mirror>

<!-- 配置方式2 --> <mirror> <id>nexus-aliyun</id>      <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>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>

本文共计1040个文字,预计阅读时间需要5分钟。

如何使用Eclipse创建一个Maven项目?

1. 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

解决方法:

1.确保已经安装了 Maven 环境。

2.检查 Eclipse 的 Maven 配置,确保 Maven 安装路径正确。

3.在 Eclipse 中,通过菜单Window -> Preferences -> Maven -> Installations 查看已安装的 Maven 安装。

4.如果没有安装,需要下载 Maven 安装包,并按照提示进行安装。

5.安装完成后,重启 Eclipse,问题应该能够解决。


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


② 出现的问题2:

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



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



3、解决:在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 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 (maven.aliyun.com/nexus/content/groups/public): The operation was cancelled. pom.xml /ssm-xml-demo line 6 Maven Project Build Lifecycle Mapping Problem


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





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



Maven 环境搭建 一、准备工作: 1、maven下载:官网:maven.apache.org/download.cgi
  • 下载完成后解压出来
2、配置环境变量
  • 细节:为什么要单独配置一个M2_HOME 的变量:方便后续学习
    • 后续使用的自动依赖的系统,比如SpringBoot、SpringCloud,它会引用M2_HOME 这个地址。
■ 添加系统变量:

□ M2_HOME maven目录下的bin目录

□ MAVEN_HOME maven的目录

如何使用Eclipse创建一个Maven项目?

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

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

  • 镜像:mirrors:

    • 作用:加速下载
    • 默认是使用国外的镜像,国内建议使用阿里云镜像加速下载

    <!-- 添加之前,先把原来的镜像全注释掉 --> <!-- 配置方式1 --> <mirror> <id>nexus-aliyun</id>      <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf> <name>Nexus aliyun</name> <url>maven.aliyun.com/nexus/content/groups/public</url> </mirror>

<!-- 配置方式2 --> <mirror> <id>nexus-aliyun</id>      <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>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>