项目特定的本地 Maven 存储库中的 JAR,如何在 Eclipse 项目中查看库?
我一直在尝试添加自定义 .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) 到一个没有中央公司 Maven 存储库的项目,而是将自定义 JAR 签入到项目目录树中的 SCM 中。我正在关注这篇文章以使其发生: Maven:通过相对路径向 jar 添加依赖项(顺便说一句,很棒的帖子)。
我所做的是:
- 将本地存储库添加到 pom.xml
- 将文件安装到本地存储库
- 将依赖项添加到 pom.xml
根据我在 m2eclipse 中看到的内容,该库已成功被 Maven 识别并添加到依赖项列表中(或者它会被称为 ? : ? 或类似的东西)
问题是 Eclipse 仍然看不到引用的库,所以这仍然失败:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
请原谅我的 Maven 新手,但我需要进行哪些更改/后续步骤:
- 让 Eclipse 看到该库,以便自动完成工作(并且可以解析导入)
- 能够编译项目
- 能够执行 mvn package 生成的 jar 吗?
谢谢!
I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).
What I did was:
- Add local repository to pom.xml
- install the file into the local repository
- Add dependency to pom.xml
Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)
The problem is that Eclipse still doesn't see the referenced lib, so this still fails:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
Pardon my maven newbiness, but what are changes / next steps I need to make to get to:
- Have Eclipse see the library so that autocomplete works (and the import can be resolved)
- Be able to compile the project
- Be able to execute the jar produced by mvn package?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在项目中的“Maven Dependency”下看到该 JAR,则 Eclipse 应该能够看到并使用它。如果它不存在,则 m2eclipse 无法正确解决依赖关系。
如果丢失,则 m2eclipse 由于某种原因无法从本地存储库下载依赖项。检查 Maven 2 控制台是否有错误和问题视图。
最后,JAR 本身可能已损坏。 Maven 不会检查这一点,它只是将文件添加到类路径中。如果 Eclipse 无法打开 JAR,您也可能会收到您提到的错误。
If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.
If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.
Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.