I have a Maven project structured as follows:
project
pom.xml(pom) parent is `spring-boot-starter-parent`
module1
pom.xml(jar) parent is project
module2
pom.xml(jar) parent is project
module3
pom.xml(jar) parent is project
In this structure, module3 depends on module1 and module2, and only module3 contains a main function.
When I navigate to the module3 directory and execute mvn spring-boot:run
, the module3 fails to start. The error message is as follows:
Failed to execute goal on project module3: Could not resolve dependencies for project module3:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: module1:jar:1.0-SNAPSHOT, module2:jar:1.0-SNAPSHOT
The solution I can currently think of is:
- In the project directory, execute:
mvn clean install
- Then navigate to the module3 directory and execute:
mvn spring-boot:run
Following this order, I can successfully start module3.
However, I would like to ask if there is any other way to directly execute mvn spring-boot:run
in the module3 directory without having to execute mvn clean install
in the project directory? Just like running the main function of module3 directly in IDEA.