1. 项目目录
2. 需求描述:
需打包server模块的Jar包,且server依赖于model和framework。
3. 代码
3.1 在项目的父pom.xml中加入以下代码,如果忽略了这一步的话打出来的jar包就不会依赖model和framework。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
</build>
3.2 在server模块的pom.xml(只需在server模块中加入build,依赖的模块不需要):
<?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">
<!--子模块必备 START-->
<parent>
<artifactId>xxx</artifactId>
<groupId>xxx</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>server</artifactId>
<!--子模块必备 END-->
<dependencies>
<!--导入相关依赖模块 START-->
<dependency>
<groupId>xxx</groupId>
<artifactId>model</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>xxx</groupId>
<artifactId>framework</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<packaging>jar</packaging>
<!--主要加入以下代码-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>xxx</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>