2018-8-28学习公司多模块项目的理解

多模块的maven的pom的主pom主要是通用的给在公共的主pom里 模块单独需要的就给在各个模块里面调用

另外 pom主要写法是

主pom

1
2
3
4
5
6
7
8
<modules>
<module>*-common</module>
/*<module>*-dal</module>公司自己改的dal一般不是这个*/
<module>*-dao</module>
<module>*-service</module>
<module>*-controller</module>
/*<module>*-app</module>公司自己改的将controller封装在里面了*/
</modules>

以下是具体的主pom实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 <modelVersion>4.0.0</modelVersion>
<artifactId>web-course</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>web-course-common</module>
<module>web-course-dal</module>
<module>web-course-service</module>
<module>web-course-app</module>
</modules>
<name>web-course</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<!--项目依赖 start-->
<dependency>
<artifactId>web-course-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>web-course-dal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>web-course-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>web-course-app</artifactId>
<version>${project.version}</version>
</dependency>

分pom

1
2
3
4
5
6
7
8
9
<parent>
<artifactId>主项目的id</artifactId>
<groupId></groupId>
</parent>
<artifactId>*-你要调取的其他层</artifactId>
<dependency>
<groupId></groupId>
<artifactId>*-你要调用的其他层</artifactId>
</dependency>

分pom实例部分代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<parent>
<artifactId>web-course</artifactId>
<groupId></groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web-course-dal</artifactId>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId></groupId>
<artifactId>web-course-common</artifactId>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>