我遇到的一些maven项目错误

导入maven项目,FIle→Import→Existing Maven Projects→找到自己想要导入的文件目录→Finish。项目就导入完成啦。接着就遇上了各种报错!!

一、Pom.xml文件第一次报错

CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.9, org.apache.maven:maven-artifact:jar:2.0.9, org.apache.maven:maven-core:jar:2.0.9: Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:jar:2.0.9 from/to central (https://repo.maven.apache.org/maven2): connect timed out。

解决方法:

这是因为网络原因,导致文件没有下载完成。

在电脑中搜索xxx.jar.lastUpdated,并将其都删除即可,具体步骤如下:

1)找到 {user}/.m2/repository

2)搜索“.lastupdated”。(如果不记得对应的.m2位置,可以全计算机搜索)Windows将展示所有文件夹的目录。

3)选中对应的lastupdated文件,并删除。

4)重新打开(若先前未关闭,请关闭后重新打开)Eclipse,右键报错的项目,并选择Maven > Update Project。同时记得勾选Force Update of Snapshots/Releases”. 点击OK,这样就解决了依赖关系。

二、Pom.xml文件再次报错

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format:or:[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1]http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

解决方法:

右击报错的项目→Properties→Project Facets→Runtimes→勾选Apache Tomcat v7.0

在Project Facets处找不到Runtimes时,需要点击下图Convert to faceted from…

三、Pox.xml最后报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mrpapp: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解决方法:

在eclipse中找到Window → Preferences → Java → Installed JREs,在jRE home中修改为你安装的jdk的目录位置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当使用IDEA进行Maven项目配置时,可能会遇到一些错误。以下是一些常见的配置错误及其解决方法: 1. 无法找到Maven安装路径:在IDEA中配置Maven时,需要指定Maven的安装路径。如果出现无法找到Maven安装路径的错误,可以检查是否正确设置了Maven的安装路径,并确保该路径下存在有效的Maven安装。 2. 无法下载依赖项:在使用Maven构建项目时,可能会遇到无法下载依赖项的错误。这通常是由于网络连接问题或Maven中央仓库的访问限制引起的。可以尝试检查网络连接是否正常,并确保Maven配置中央仓库的URL正确。 3. 依赖项版本冲突:当项目中存在多个依赖项,并且它们之间存在版本冲突时,可能会导致编译错误或运行时异常。解决方法是通过在pom.xml文件中显式指定依赖项的版本号,或者使用Maven的依赖管理功能来解决版本冲突。 4. 缺少插件或插件版本不兼容:在使用Maven构建项目时,可能会遇到缺少插件或插件版本不兼容的错误。这通常是由于pom.xml文件中配置的插件不存在或版本不匹配引起的。可以尝试更新插件版本或使用与IDEA兼容的插件。 5. Maven构建失败:在使用Maven构建项目时,可能会遇到构建失败的错误。这可能是由于代码错误、配置错误或其他原因引起的。可以尝试查看IDEA的构建日志或Maven的详细输出,以了解具体的错误信息,并根据错误信息进行修复。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值