How can maven packaged projects and dependencies be packaged successfully without being in the same directory?

the code that introduced submodule,submodule into the project is placed in another folder. Now the main project directory failed to package with the mvn install command. I can"t find the submodule project. I don"t know how to configure the project directory. Do I need to modify the pom file?

May.12,2021

you can use relative paths in pom.xml to specify the location of submodule, such as

parent project

<modules>
  <module>../module1</module>
  <module>../module2</module>
  <module>../module3</module>
</modules>

in sub-module

<parent>
  <groupId>my.awsome.module1</groupId>
  <artifactId>parent-pom</artifactId>
  <version>1.0.1<version>
  <relativePath>../parent-pom/pom.xml</relativePath>
</parent>

but obviously this is not a good practice, and it is best to replan the project path to avoid all kinds of subtle minor problems caused by this.

Menu