目录:
- 1、pom文件的配置
- 2、新建assembly的描述文件
- 3、maven打包
1、pom文件的配置
<!--maven构建-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 添加assembly插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptors>
<!-- 指定assembly描述符文件的路径 -->
<descriptor>src/assembly/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2、新建assembly的描述文件
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<!-- 配置依赖如何打包 -->
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<!-- 配置外部文件夹如何打包 -->
<directory>filestore</directory>
<outputDirectory>${file.separator}/filestore</outputDirectory>
</fileSet>
</fileSets>
</assembly>
3、maven打包
最终依赖包以及项目jar包和filestore文件夹等都打到了最后一个jar总包里面了。