Maven如何将Java项目作为依赖

发布于 2025-02-10 04:46:32 字数 531 浏览 0 评论 0原文

我在Eclipse中具有以下结构

-->Project1 (Java SE Project)
---->src (My Java Code)

-->Project2 (Maven Project)
---->pom.xml
---->src
------->main
------->test

,我可以配置Maven项目的构建路径以包括Project1,并且在IDE中运行良好。 时,似乎

mvn test-compile

但是,我意识到,当我想以命令为命令时,Project2找不到该项目 。我认为我需要以某种方式将其引用在我的pom.xml中(然后,我可以忽略Eclipse中的步骤以在构建路径上进行配置)。

错误是

[ERROR] package foo does not exist

Project1并没有真正被编译到.jar中,因此这不是解决方案。我希望实际的整个项目以某种方式作为参考。

I have the following structure

-->Project1 (Java SE Project)
---->src (My Java Code)

-->Project2 (Maven Project)
---->pom.xml
---->src
------->main
------->test

In Eclipse, I can configure the build path of the maven project to include Project1 and it runs fine in the IDE. However, I realized that it seems when I want to run it as a command

mvn test-compile

the Project2 can't find the project. I am thinking I need to somehow reference it in my pom.xml (which then, I can ignore the step in Eclipse to configure it on the build path).

The error is

[ERROR] package foo does not exist

The Project1 is not really being compiled into a .jar so that isn't the solution. I want the actual entire project as a reference somehow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈下烟灰 2025-02-17 04:46:32

取而代之的是,我所做的只是将Project1转换为Maven项目,在Project2中,添加了依赖项而无需生成JAR。似乎Maven足够聪明,可以找到该项目而不查看.M2版本(就像我进行了MVN安装一样)。

Instead what I did was just convert the project1 to a maven project and in project2, added the dependency without needing to generate the jar. Seems like maven is smart enough to find the project and not look into the .m2 version (like if I did a mvn install).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文