依赖项和工作区项目
我正在开发一个名为 Utils 的 Maven 项目。我还有另一个项目,称为 A,它使用 Utils 类。因此,我在 A 的 POM 中添加了对 Utils 的依赖。我准确地说,这两个项目没有安装在本地存储库(或另一个私有存储库)中。当我尝试打包项目 A 时,出现错误,因为 Maven 尝试从本地存储库和中央存储库获取 Utils 项目,但它不在那里。我不想安装该项目,因为它不是最终版本,我不想给它一个版本,因为没有发布。
谢谢
I have a Maven project called Utils that i'm working on. I also have another project, called A, that uses classes of Utils. So, I've added a dependency to Utils in the POM of A. I precise that the two projects are not installed in the local repository (or another private repository). When I try to package the project A, I get an error because Maven tries to get the Utils project from the local repository and central repository, but it's not there. I don't want to install the project because it's not final, i don't want to give it a version because there is no release.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将项目安装到本地存储库是安全的。只需在 Utils 的项目文件夹中使用
mvn install
即可。每当您安装
时,它都会被本地存储库中的最新版本替换。但不要部署它,这意味着其他人可以使用它。相比之下,您的本地存储库仅由您使用。
It's safe to install the project into local repository. Just use
mvn install
in the Utils' project folder. Anytime you doinstall
it will be replaced by newest in your local repo.But don't deploy it, it means others could use it. In comparison, your local repo is used only by you.
看来Eclipse上的Maven插件提供了这种可能性。并且不需要在本地存储库中安装与活动项目相对应的工件。该插件似乎将工作区视为第二个本地存储库(您可以使用 Maven 存储库视图查看这一点)。首先,必须启用工作区解析功能(右键单击项目,然后在 Maven 下)。当我想运行项目时,我使用运行配置向导,并且必须选中解决工作空间。
这是一个好的解决方案吗?我不知道它只是看起来有效还是真的有效。
谢谢
It seems that the Maven plugin on Eclipse provides this possibility. And there is no need to install the artifacts corresponding to the active projects in the local repository. It seems that the plugin considers the workspace as a second local repository (you can see this using the Maven repositories view). First, the Workspace resolution feature must be enabled (Right click on the project then under Maven). When I want to run the project, I use Run configurations wizard, and Resolve workspace must be checked.
Is it a good solution? I don't know if it just seems to work or if it really works.
Thanks