Note: This article is based on a simple idea to create a multi-module project. Hoping to help people who are new to this, I Meng new one, if wrong, hope understanding.
1. Create a blank project maven
a new idea maven project as a parent project, follow these steps:
Fill in your own groupId and artifactid, read the following do not know if groupId and artifactId, you can view this: https://www.cnblogs.com/panxuejun/p/6184072.html
groupId :the unique identifier of the organization or group that created the project
artifactId :unique base name of the primary artifact being generated by this project
GroupID project organization unique identifier, corresponding to the actual structure of the JAVA package, main directory is the directory structure of java.
ArtifactID is a unique identifier of the item, corresponding to the actual name of the project, is the name of the project root directory.
Input the path name works, and works, click on the finish, even if the construction project finished.
Src directory can be deleted, the parent project does not store the code
maven introduced springboot dependent, the code attached pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.demo.moduals</groupId> <artifactId>moduals</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <!-- 公共依赖 --> </dependencies> </project>
maven environment configuration:
The idea to open the Settings window, modify maven configuration (default is C: \ Users \ .m2), maven Download: http://maven.apache.org/download.cgi
2. Add a function module modual1
Select the parent project, the same as the right mouse button to select new-> modual, followed by the new maven project
When created, the project is structured as follows:
3. The construction of a main module webapp
Module and create the same front, webapp to use modual1 class, maven add dependencies:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>moduals</artifactId> <groupId>com.demo.moduals</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.demo.moduals.webapp</groupId> <artifactId>webapp</artifactId> <dependencies> <!-- 模块依赖 --> <dependency> <groupId>com.demo.moduals.modual1</groupId> <artifactId>modual1</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
Summary: IDEA multiple modules to create probably the case.