[英]Maven how to include a Java project as a dependency
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.在 Eclipse 中,我可以将 maven 项目的构建路径配置为包含 Project1,它在 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. Project2 找不到该项目。 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).
我想我需要以某种方式在我的 pom.xml 中引用它(然后,我可以忽略 Eclipse 中的步骤以在构建路径上配置它)。
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. Project1 并没有真正被编译成 .jar,所以这不是解决方案。 I want the actual entire project as a reference somehow.
我希望以某种方式将实际的整个项目作为参考。
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.相反,我所做的只是将 project1 转换为 maven 项目,然后在 project2 中添加依赖项,而无需生成 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).
似乎 maven 足够聪明,可以找到项目而不是查看 .m2 版本(就像我安装了 mvn 一样)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.