1. Create the parent project first
- Inside Eclipse New -> ;
Maven Project
- Select "Create a simple project" in the pop-up interface
In this way, we have created a Maven project according to the regular version. We also need to modify this project. Note: Packaging is of type pom.
Because this is a parent project and does not need any source code, then we delete all unused directories under this project in Eclipse, leaving only the files.pom.xml
2. Create sub-projects
Select the newly created parent project (wyp.ssm.db.bus) and click New -> in the pop-up menu Other ->
Maven Module;
Use default Archetype (default: GroupId : org.apache.maven.archetypes, Artifact Id : maven-archetype-quickstart)
Write the name of the Module to be created, for example: wyp.ssm.db.pojo, as shown below:
Such a sub-project is created. In the file system, the sub-project will be built in the directory of the parent project, as shown below:
The pom file and project structure in the project are shown as follows:
3. Add references between submodules
For example: mapper project add drinking pojo project:
pojo / pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.bus</artifactId> <version>1.0.0</version> </parent> <name>wyp.ssm.db.pojo</name> <artifactId>wyp.ssm.db.pojo</artifactId> </project>
mapper/pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.bus</artifactId> <version>1.0.0</version> </parent> <name>wyp.ssm.db.mapper</name> <artifactId>wyp.ssm.db.mapper</artifactId> <dependencies> <dependency> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.pojo</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
springmvc/pom.xml
<dependency> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.pojo</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.mapper</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>wyp.ssm.db.bus</groupId> <artifactId>wyp.ssm.db.service</artifactId> <version>${project.version}</version> </dependency>