Main下添加文件
下添加assembly—package.xml
<?xml version='1.0' encoding='UTF-8'?>
<assembly>
<!--打包名称,唯一标识-->
<id>${project.build.finalName}</id>
<!--打包格式,可以手动修改-->
<formats>
<format>zip</format>
</formats>
<!--文件设置-->
<fileSets>
<fileSet>
<!--目标目录,会处理目录里面的所有文件-->
<directory>${project.basedir}/src/main/resources</directory>
<!--相对于打包后的目录-->
<outputDirectory>config</outputDirectory>
<!--文件过滤-->
<includes>
<include>*.*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.*</include>
</includes>
<!--文件权限-->
<fileMode>0755</fileMode>
<!--如果是脚本,一定要改为unix.如果是在windows上面编码,会出现dos编写问题-->
<lineEnding>unix</lineEnding>
</fileSet>
<!-- 将第三方依赖打包到lib目录中 -->
<fileSet>
<directory>${basedir}/target/lib</directory>
<outputDirectory>lib</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<!-- 将项目启动jar打包到boot目录中 -->
<fileSet>
<directory>${basedir}/target</directory>
<outputDirectory>lib</outputDirectory>
<fileMode>0755</fileMode>
<includes>
<include>${project.name}.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
添加bin
在main下添加bin 添加bat
Bat文件
@echo off
rem startup jar
cd ../lib
java -jar logmm.jar
pause
Pom.xml
<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<!--主要使用的是maven提供的assembly插件完成-->
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<!--具体的配置文件-->
<descriptors>${project.basedir}/src/main/assembly/package.xml</descriptors>
</configuration>
<id>make-assembly</id>
<!--绑定到maven操作类型上-->
<phase>package</phase>
<!--运行一次-->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>