说明
上一章我们搭建好了springboot的基础框架并引入了shiro和自动化代码生成工具,今天我们增加一个集成工具assembly,这样可以按照我们需要的风格进行打包。
引入
在src下新建assembly.xml内容如下:
<assembly>
<id>bin</id>
<formats>
<!--支持 zip,tar,tar.gz,tar.bz2,jar,dir,war 等 -->
<format>tar.gz</format>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/assembly/conf</directory>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${profile.dir}</directory>
<outputDirectory>conf</outputDirectory>
<!-- 表示的是包含下面格式的资源文件 -->
<includes>
<include>*.xml</include>
<include>*.properties</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>src/assembly/bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>src/assembly/logs</directory>
<outputDirectory>logs</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
增加脚本配置
脚本参考:https://www.jianshu.com/p/719133b1bad5
示例
pom引入
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/*.ttf</exclude>
<exclude>**/*.woff</exclude>
</excludes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.ttf</include>
<include>**/*.woff</include>
</includes>
</resource>
</resources>
结果
重新maven打包,结果我们发现如下结构:
解压zip包会得到如下目录
说明
- 本文只做学习参考,如有任何不准确的地方欢迎指正。
- 源码参考 :https://gitee.com/lulongji/springboot-demo.git
- 我的邮箱:
lulongji2011@163.com
版权声明:
本文为博主原创文章,转载请附上原文出处链接和本声明。