有任何方法可以使用“工作区项目”吗? Maven 存储库?
我们有:Eclipse 3.6、Maven (M2Eclipse)、两个带有 pom.xml 的项目(ProjectA 和 ProjectB)。
ProjectB 依赖于 ProjectA(使用 Maven)。
如果我们将 ProjectA 安装到本地存储库(maven install),ProjectB 可以解决依赖关系。
如果我们不将 ProjectA 安装到本地存储库。在 Maven POM 编辑器中,我们添加 ProjectA 作为 ProjectB 的依赖项(M2Eclipse 使用“工作空间项目”存储库来解决此依赖项)。
好的,已添加。但是,如果我们执行“maven package”或其他插件目标...依赖关系未解决。 我们有类似的东西:
下载:http://repo1.maven。 org/maven2/Artifact/ProjectA/maven-metadata.xml
当然无法解析。
现在是问题。构建ProjectB时如何使用“工作区项目”?
PS 为什么我不使用“maven install”?好的,这是 100% 的方法,但是当我做很多小的改变时,做多余的操作就太长了。
PSS“工作空间项目”我们可以看到Window ->显示视图-> Maven 存储库。
We have: Eclipse 3.6, Maven (M2Eclipse), Two Project (ProjectA and ProjectB) with pom.xml.
ProjectB depends of ProjectA (using maven).
If we install ProjectA to local repository (maven install), ProjectB resolve dependencies OK.
If we not install ProjectA to local repository. In Maven POM Editor we add ProjectA as dependency of ProjectB (M2Eclipse using "workspace project" repository to resolve this dependency).
OK, added. But if we do "maven package" or others plugins goals... dependency not resolved.
And we have somethings like that:
Downloading: http://repo1.maven.org/maven2/Artifact/ProjectA/maven-metadata.xml
and of course it cannot be resolved.
Now is the Question. How I can use "Workspace project" when build ProjectB?
P.S. Why I'm not using "maven install"? OK, it is 100% method, but when I do many small changes in several it is too long do excess operations.
P.S.S. "Workspace project" we can see Window -> Show View -> Maven Repositories.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为从 Eclipse 运行“Maven 包”或类似目标的想法是执行 Maven 在从命令行运行时会执行的任何操作。您给出的场景也不适用于命令行。
如果项目 B 依赖于项目 A(通过 pom.xml),则意味着项目 A 应该在存储库中可用。无论是本地(通过 mvn install)还是远程(mvn deploy)都没关系,但 mvn package 还不够。这只会将一个包放入 /target 文件夹中。
唯一的例外是,如果两个项目都驻留在同一个反应器中,我认为这两个项目都是其他“父”项目的模块。在这种情况下,在子模块之一上触发 Maven 目标可能能够解决依赖关系。但不是 100% 确定。
回到你的问题:“现在是问题。在构建 ProjectB 时如何使用“工作区项目”?”。不,我不这么认为。
I think the idea of running the 'Maven package' or similar goals from Eclipse is to do whatever maven would have done if run from the commandline for example. The scenario that you are giving wouldn't have worked on the commandline either.
If project B depends on project A (via pom.xml) that means that project A should be available in a repository. Whether that's local (via mvn install) or remote via (mvn deploy) doesn't matter, but mvn package isn't enough. That will just put a package in the /target folder.
The only exception would be if both projects reside in the same reactor I suppose, that is both projects are modules of some other 'parent' project. In that case triggering maven targets on one of the submodules might be able to resolve the dependencies okay. Not 100% sure though.
Back to your question: "Now is the Question. How I can use "Workspace project" when build ProjectB?". No, I don't think so.
应该解决工作区依赖性。试试这个,
<块引用>
运行>运行配置> Maven 构建>新的>选择项目B>检查“解决工作空间工件”>将目标设置为
package
同时选择离线复选框。
也许,您需要在项目B依赖标记中提供项目A的准确
版本
。否则,它可能会寻找 Maven 公共存储库来获取最新版本。希望这有帮助。
Workspace dependency should be resolved. Try this,
Perhaps, you need to provide exact
version
of projectA in projectB dependency tag. Else, it may look to Maven public repository to pull the latest.Hope this helps.
试试这个(在 ProjectB 中):
这里以这种方式解决了类似的问题。
Try this (in ProjectB):
A similar issue was solved here in that way.