Eclipse配置了MAVEN,但是MAVEN工程无法拉去依赖包
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse配置了MAVEN,但是MAVEN工程无法拉去依赖包相关的知识,希望对你有一定的参考价值。
Multiple annotations found at this line:
- Execution default-testResources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:testResources failed: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could
not be resolved: junit:junit:jar:3.8.1, org.codehaus.plexus:plexus-utils:jar:2.0.5, org.apache.maven.shared:maven-filtering:jar:1.1,
org.sonatype.plexus:plexus-build-api:jar:0.0.4, org.codehaus.plexus:plexus-interpolation:jar:1.13: Failure to transfer junit:junit:jar:3.8.1 from
mirrors.ibiblio.org/maven2/): Connection reset (org.apache.maven.plugins:maven-resources-plugin:2.6:testResources:default-
testResources:process-test-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile
(execution: default-testCompile, phase: test-compile)
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.5.1 or one of its
mirrors.ibiblio.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio has
elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:jar:2.5.1 from/
maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio has elapsed or updates
mirrors.ibiblio.org/maven2/): Connection reset
cached in the local repository, resolution will not be reattempted until the update interval of ibiblio has elapsed or updates are forced.
Connection reset
maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio has elapsed or updates
mirrors.ibiblio.org/maven2/): Connection reset
- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could
not be resolved: junit:junit:jar:3.8.1, org.codehaus.plexus:plexus-utils:jar:2.0.5, org.apache.maven.shared:maven-filtering:jar:1.1,
org.sonatype.plexus:plexus-build-api:jar:0.0.4, org.codehaus.plexus:plexus-interpolation:jar:1.13: Failure to transfer junit:junit:jar:3.8.1 from
mirrors.ibiblio.org/maven2/): Connection reset (org.apache.maven.plugins:maven-resources-plugin:2.6:resources:default-
resources:process-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
(execution: default-compile, phase: compile)
1、首先去看看你的镜像库是不是正确,可以在settings.xml中看看你的镜像库指向的位置,是否是可以访问的
2、如果判断出你的jar引入的位置都是无法加载的,自然就报错了
eclipse配置和创建maven工程
在eclipse配置maven之前需要我们做好准备工作,如下:
1. 安装jdk
2. 已安装好 maven,将maven配置成功
3. 下载Eclipse,解压缩安装完成,建立工作空间。
这些内容相信大家都已经轻车熟路了,如果不会,请大家查看上篇博文,这里就不再累述了。
eclipse配置maven
检查eclipse的maven插件是否安装成功,如图:
若没有安装maven插件,我们需要先安装maven插件。
安装maven插件
eclipse安装插件有常用两种方式,在线方式和离线方式。这两种安装方式我建议大家使用离线方式,离线方式更加方便,简单,这两中安装方式网上的资料很多,也非常简单,我就不再累述了。给大家推荐一篇即可:
配置maven
- 配置maven安装目录
依次打开Window –> Perferences –> Maven ,展开Maven的配置界面,如上图;
然后点击Installations –> add 选择maven安装目录,这里我的Maven安装目录为D:\maven\apache-maven-3.2.3,选择你的Maven安装目录,并点击确定, 之后可以点击Apply,点击OK,即可完成 - 然后, 我们在Maven的配置界面,设置User Settings
Global Settings选择maven 安装目录下conf文件夹下的settings.xml,这里我的Maven安装目录为D:\maven\apache-maven-3.2.3\conf\settings.xml,选择你的Maven安装目录,检查Local Repository 项,如果为D:/maven/repository则配置成功,否则重新配置上一步。
恭喜你,现在我们已经配置好了eclipse,下面,我们可以创建maven项目了。
创建maven项目
- 我们在Eclipse菜单栏中点击File->New->Other->Maven,在弹出的对话框中会看到,如下图所示:
- 选择Maven Project,请选中Create a simple project(skip archetype selection),之后点击Next
- 填写Group id和Artifact id, Version默认,Packaging默认为jar,Name,Description选填,其他的不填
之后点击Finish即可,如图所示:
4. 前三步就可以创建一个简单的maven项目,如果我们想创建一个Maven的web项目,把第三步的Packaging的类型改为war,之后点击Finish即可,如图所示:
以上是关于Eclipse配置了MAVEN,但是MAVEN工程无法拉去依赖包的主要内容,如果未能解决你的问题,请参考以下文章