sspringboot項目如果不想每次修改配置文件就要重新打包jar的話,可以進行以下配置進行打包
1.
在resources下新建assembly文件夾package.xml
<?xml version="1.0" encoding="UTF-8"?> <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>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>com.xx.xx.xxxxApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<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/assembly/package.xml</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包.
