Maven如何将Java项目作为依赖
我在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取而代之的是,我所做的只是将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).