Sub-module construction of maven projects, inheritance between projects, project aggregation, sub-module construction projects

Insert picture description here

1. Demonstration of inheritance between projects:

Insert picture description here

Parent project

First create a skeletonless maven parent project (written in pom)
Insert picture description here
Insert picture description here

Subproject:

To create a skeletonless maven project, remember to select the parent and select the project button:
Insert picture description herethen its pom.xml is automatically generated, and you can see that it automatically inherits the coordinates of the parent project:
Insert picture description here

2. Project aggregation (convenient packaging only)

Insert picture description here

There is no half a dime relationship between aggregation and inheritance. Even if you have no inheritance relationship, you can write the aggregation relationship modules tag . Here, for convenience, I will take the above two sub-parent projects as examples.

Just write and aggregate other modules in the big project, and you don't need to write other modules. Here it is assumed that maven_parent is a large project for Mao, and I want to aggregate other small projects:
Insert picture description hereThen click on the right to package, first enter clear, package:Insert picture description here

Successfully packaged:
Insert picture description here

Three, sub-module construction project

Because of aggregation or something, your subproject can be created in the parent project directory or outside the parent project. Now demonstrate the inside:
Insert picture description here
although the above subprojects are inherited from the parent project, the jar is generally locked in the parent project value version The package is only (excluding dependencies), and the coordinates need to be imported in the subproject (you don't need to write the version number, because the parent project is locked). Then the sub-projects can be relied on, so don’t write so many coordinates:
Insert picture description here
maven_pojp does not need to import the above coordinates, and then import the coordinates in maven_dao, then maven_service depends on maven_dao, maven_web (usually need to import a little coordinate) depends on maven_service :Insert picture description here

Insert picture description here

Then when deploying, you only need to deploy maven_web in tomcat8 instead of maven_parent. In fact, deploy maven_web, it will automatically help you package maven_pojo, maven_dao, and maven_service as jars and put them in the lib directory of maven_web
Insert picture description here

Guess you like

Origin blog.csdn.net/GLOAL_COOK/article/details/113763685