Java Eclipse - Maven - 依赖项不会自动反映
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20734698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse - Maven - Dependencies not getting automatically reflected
提问by Sandeep
I have installed
我已经安装
- Java 1.7
- Eclipse Juno
- From Eclipse Market place have installed - Maven Integration for Eclipse WTP (a.k.a m2e-wtp), m2e-apt, Spring IDE, The Spring Tool Suite? (STS)
- Have defined
M2_HOME
as directory where Maven is installed. PATH updated as%M2_HOME%/bin
- 爪哇 1.7
- 日食朱诺
- 从 Eclipse 市场已经安装了 - Eclipse WTP 的 Maven 集成(又名 m2e-wtp)、m2e-apt、Spring IDE、Spring 工具套件?(STS)
- 已定义
M2_HOME
为安装 Maven 的目录。路径更新为%M2_HOME%/bin
I am working on Windows XP.
我正在使用 Windows XP。
I am able to create a Maven project but when trying to add Dependencies (select pom.xml
- Dependencies - Add) artifactId
's "Enter groupId, artifactId or sha1 prefix or pattern
" which are inputted are not getting displayed. Say if I input "springframework", it only reflect the jars that installed locally and don't search over the internet.
Also if I check Maven Repositories (select by Windows - Show Views - Others - Maven - Maven Repositories), nothing is shown in Global Repositories - central (http://repo.maven.apache.org/maven2).
我能够创建一个 Maven 项目,但是当尝试添加依赖项(选择pom.xml
- 依赖项 - 添加)artifactId
的“ Enter groupId, artifactId or sha1 prefix or pattern
”时,输入的“ ”没有显示出来。假设我输入“springframework”,它只反映本地安装的 jars 而不会在互联网上搜索。此外,如果我检查 Maven 存储库(通过 Windows 选择 - 显示视图 - 其他 - Maven - Maven 存储库),则全局存储库中没有显示任何内容 - 中央(http://repo.maven.apache.org/maven2)。
In case, if I manually put required artifactID
in pom.xml
and then update maven it downloads the required jars.
在情况下,如果我手动把需要artifactID
的pom.xml
,然后更新的maven在下载所需要的罐子。
I am working on my home computer where I don't have any proxies and has set following in local m2 settings (C:\Documents and Settings\Sandy\.m2\Settings.xml
)
我在我的家用电脑上工作,我没有任何代理,并且在本地 m2 设置中设置了以下 ( C:\Documents and Settings\Sandy\.m2\Settings.xml
)
Can you please advise, what setting I need to do so that inputted artifact's can be added using add Dependencies option?
您能否建议我需要进行哪些设置才能使用添加依赖项选项添加输入的工件?
Thanks in advance
提前致谢
采纳答案by Sandeep
Finally issue got resolved :) :)
终于问题解决了:) :)
Here what was done:
这里做了什么:
- Followed @khmarbaise, @SaifAsif, @Adrian comments :) Thanks for them I was able to understand the overlooked configurations
- Installed Eclipse Kepler (I was using Eclipse Juno) and Spring IDE from marketplace
- Maven Download setting as shown by @khmarbaise
- Copied global setting of maven (f:\maven\conf\settings.xml) to my local setting (C:\Documents and Settings\Sandy.m2). I didn't modified any thing in it.
- Windows - System environment variables were set
- M2_HOME - To the local installion (f:\Maven)
- M2 - %M2_HOME%\bin
- JAVA_HOME (already exist) - f:\java
- PATH - %M2%;%JAVA_HOME%\bin
- CLASSPATH - %JAVA_HOME%
- 关注@khmarbaise、@SaifAsif、@Adrian 评论 :) 感谢他们,我能够理解被忽视的配置
- 安装了 Eclipse Kepler(我使用的是 Eclipse Juno)和来自市场的 Spring IDE
- Maven 下载设置如@khmarbaise 所示
- 将 maven 的全局设置 (f:\maven\conf\settings.xml) 复制到我的本地设置 (C:\Documents and Settings\Sandy.m2)。我没有修改其中的任何内容。
- Windows - 设置了系统环境变量
- M2_HOME - 到本地安装 (f:\Maven)
- M2 - %M2_HOME%\bin
- JAVA_HOME (已经存在) - f:\java
- 路径 - %M2%;%JAVA_HOME%\bin
- 类路径 - %JAVA_HOME%
At end I was able to see the dependencies automatically.
最后,我能够自动查看依赖项。
Thanks!
谢谢!
回答by Saif Asif
Also if I check Maven Repositories (select by Windows - Show Views - Others - Maven - Maven Repositories), nothing is shown in Global Repositories - central(http://repo.maven.apache.org/maven2).
此外,如果我检查 Maven 存储库(通过 Windows 选择 - 显示视图 - 其他 - Maven - Maven 存储库),则全局存储库中没有显示任何内容 - 中央(http://repo.maven.apache.org/maven2)。
It is most likely that your central Repository index might never have been updated. To resolve it , Go to Window> Show View> Other> type Mavenin filter and select Maven Repositories. In Maven Repositoriestab Expand Global Repositories, Right-click on central and Update Index.
您的中央存储库索引很可能从未更新过。要解决它,请转到窗口>显示视图>其他>在过滤器中键入Maven并选择Maven 存储库。在Maven Repositories选项卡中展开Global Repositories,右键单击 central 和Update Index。
The process will initially take about a few minutes depending on the network speed but once its done, the search box will start showing results when-ever you type in the name of any jar
该过程最初需要大约几分钟时间,具体取决于网络速度,但一旦完成,搜索框将开始显示结果 - 无论何时您输入任何 jar 的名称
回答by khmarbaise
The configuration for Eclipse can be found here:
Eclipse 的配置可以在这里找到:
The screen shot is from Mac OS but also on Windows you will find this under preferences -> Maven.
屏幕截图来自 Mac OS,但在 Windows 上,您可以在首选项 -> Maven 下找到它。