springboot使⽤maven命令打包jar及配置⽂件配置sspringboot项⽬如果不想每次修改配置⽂件就要重新打包jar的话,可以进⾏以下配置进⾏打包
1.在resources下新建assembly⽂件夹l
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/plugins/maven-assembly-plugin/assembly/1.1.3 /xsd/assembly-1.1.3.xsd"> <id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- 把项⽬相关的说明⽂件,打包进zip⽂件的根⽬录 -->
<!-- <fileSet>
<directory>${project.basedir}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
<include>build.info</include>
</includes>
</fileSet> -->
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory></outputDirectory>
</fileSet>
<!-- 把项⽬⾃⼰编译出来的jar⽂件,打包进zip⽂件的根⽬录 -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
2.在pom中配置下⾯代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix></classpathPrefix>
<mainClass&xxxxApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
maven打包本地jar包<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<!-- The configuration of the plugin -->
<configuration>
<!-- Specifies the configuration file of the assembly plugin -->
<descriptors>
<descriptor>src/main/resources/l</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
然后在项⽬⽂件夹下shift+右键打开命令⾏窗⼝输⼊:mvn package -DskipTests 回车,会在target⽂件夹下⽣成zip包.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论