1. Demonstration of inheritance between projects:
Parent project
First create a skeletonless maven parent project (written in pom)
Subproject:
To create a skeletonless maven project, remember to select the parent and select the project button:
then its pom.xml is automatically generated, and you can see that it automatically inherits the coordinates of the parent project:
2. Project aggregation (convenient packaging only)
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:
Then click on the right to package, first enter clear, package:
Successfully packaged:
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:
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:
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 :
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