简体   繁体   English

IntelliJ的一个Maven项目取决于另一个Maven项目:如何提高效率?

[英]IntelliJ with one Maven project depending on another Maven project: How to be efficient?

My team is regularly facing inconveniences when running a Maven project that depends on other Maven projects which were modified but not reinstalled to the local repository. 在运行依赖于已修改但未重新安装到本地存储库的其他Maven项目的Maven项目时,我的团队经常会遇到麻烦。

For the sake of simplification, let's say I have two Maven projects Business and Web . 为了简化起见,假设我有两个Maven项目BusinessWeb My Web project has in its dependencies the Business project, and a Jetty plugin which allows me to run a local web server for development. 我的Web项目在其依赖项中有Business项目,还有一个Jetty插件,该插件使我可以运行本地Web服务器进行开发。

In IntelliJ, both projects are opened on the same window using Maven Add project, so that I can navigate through the code easily between the two projects. 在IntelliJ中,使用Maven Add项目在同一个窗口中打开了两个项目,因此我可以轻松地在两个项目之间浏览代码。

Currently, I have set up a Run Configuration in IntelliJ so that mvn clean install -DskipTests will run on the Business project, and then mvn clean jetty:run on Web . 当前,我已经在IntelliJ中设置了一个运行配置,以便mvn clean install -DskipTests将在Business项目上运行,然后mvn clean jetty:run web上 mvn clean jetty:run This allows me to run Web with the latest modifications made in Business . 这使我可以使用Business中进行的最新修改来运行Web If I don't run clean install on the Business project, then Web will run on an older version of the source code of Business . 如果我不在Business项目上运行clean install ,则Web将在Business源代码的旧版本上运行。 In addition this will mess up the IntelliJ debugger as the source code being debugged will not match the runtime class. 另外,由于要调试的源代码与运行时类不匹配,这将使IntelliJ调试器混乱。

In a real application, a Dependency Injection Bootstrap project may depend on Web , Business , Some Database Adapter X , Some Database Adapter Y , Some API Client Adapter ... therefore the clean install may become costly. 在实际的应用程序中, 依赖项注入引导项目可能取决于Web业务某些数据库适配器X某些数据库适配器Y某些API客户端适配器 ...因此, clean install可能会变得很昂贵。 In addition it is easy to forget to build the dependee project, which is the reason why the Maven goals are always run before running Jetty. 此外,很容易忘记构建受抚养人项目,这就是为什么在运行Jetty之前始终运行Maven目标的原因。

Is there a way to be more efficient during development, so that a modification on a dependee project will be active when running the dependant projects without having to run any/many Maven goals? 有没有一种方法可以在开发过程中提高效率,以便在运行依赖项目时无需执行任何/许多Maven目标的情况下,就可以对依赖项目进行修改?

Create a tiny parent project pom.xml which references both Business and Web as modules. 创建一个微型父项目pom.xml,该项目将Business和Web都引用为模块。 Then tell Intellj to open the parent project - this will let Web access Business (if properly referenced) without having to install the artifacts locally. 然后告诉Intellj打开父项目-这将使Web访问Business(如果正确引用),而不必在本地安装工件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM