Eclipse中的maven项目引入jar报错的解决方式
2020-04-18 16:03:02来源:博客园 阅读 ()
Eclipse中的maven项目引入jar报错的解决方式
Eclipse中maven项目引入jar包异常的解决方式,maven下载jar中断后出现异常的解决方式一、背景
最近在学习ES的使用,先是在一个电脑上写的测试代码,然后代码复制另一台电脑上,没想到maven项目里的pom.xml居然报错了。所以在这里记录一下解决的方式。
(异常是复现的,非第一现场,仅作示例)
二、问题表现
1、从项目上看的表现
2、打开pom的表现
3、定位到×的地方
null (org.apache.maven.plugins:maven-jar-plugin:2.4:jar:default-jar:package) org.eclipse.core.runtime.OperationCanceledException at
org.eclipse.core.runtime.SubMonitor.checkCanceled(SubMonitor.java:604) at org.eclipse.core.internal.resources.Resource.setDerived(Resource.java:1611) at
org.eclipse.m2e.core.internal.M2EUtils.createFolder(M2EUtils.java:73) at
org.sonatype.m2e.mavenarchiver.internal.AbstractMavenArchiverConfigurator.writePom(AbstractMavenArchiverConfigurator.java:772) at
org.sonatype.m2e.mavenarchiver.internal.AbstractMavenArchiverConfigurator$1.build(AbstractMavenArchiverConfigurator.java:161) at
org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137) at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172) at
org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1) at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) at
org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99) at
org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86) at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200) at
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246) at
org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360) at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142) at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
还有一个×(有时有的×能点,有的不能点)
Multiple annotations found at this line:
- Failure to transfer org.apache.httpcomponents:httpcore:jar:4.4.12 from http://maven.***.com:port/nexus/content/groups/public was cached in the local repository, resolution will not be
reattempted until the update interval of nexus-public-corp-releases has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.httpcomponents:httpcore:jar:4.4.12 from/to
nexus-public-corp-releases (http://maven.***.com:port/nexus/content/groups/public): The operation was cancelled. org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer
org.apache.httpcomponents:httpcore:jar:4.4.12 from http://maven.***.com:port/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update
interval of nexus-public-corp-releases has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.httpcomponents:httpcore:jar:4.4.12 from/to nexus-public-corp-releases
(http://maven.***.com:port/nexus/content/groups/public): The operation was cancelled. at
org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238) at
org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246) at
org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367) at
org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205) at
org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:215) at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:188) at
org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:119) at org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:636) at
org.eclipse.m2e.core.internal.project.registry.DefaultMavenDependencyResolver.resolveProjectDependencies(DefaultMavenDependencyResolver.java:63) at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:530) at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:492) at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177) at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) at
三、定位、解决问题
1、定位问题
从上述的那个×的描述,可以看到原因。
org.eclipse.core.runtime.OperationCanceledException
操作被取消异常。
也就是在引入依赖的时候,maven还在下载jar包时被终止了。
我的项目出现上述异常,就是因为下的过程中网络卡了,然后我就手动结束了下载过程。
这种问题之前遇到过,当时总怀疑是项目结构有问题,或者jar有问题,没有想到是这个原因。
这次又遇到这个问题的时候,我回想,在自己电脑上都正常,在公司电脑就有问题?不应该。
问题定位了,接下来就是解决问题了。
2、解决问题
打开项目的Build Path,可以看到Libraries中的Maven依赖那块有×。
展开之后,就可以看到是哪个jar包异常。
根据路径找到本地的maven仓库对应的路径。可以点进去看一下,有几个文件,但是没有jar文件。
解决方法:删除4.4.12这个文件夹。然后随意改动一下pom.xml后保存,让Eclipse重新下一下,问题就解决了。
原文链接:https://www.cnblogs.com/shuimutong/p/12724594.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- MyBatis中的$和#,用不好,准备走人! 2020-06-11
- 构造函数中的this()和super() 2020-06-10
- eclipse下创建Maven项目(包含webapp目录结构) 2020-06-09
- Maven安装与配置 2020-06-09
- 怎么用Java 高效提取、替换、删除PDF文档中的图片 2020-06-09
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash