spring-boot使⽤maven打包独⽴配置资源⽂件l备忘
<build>
<finalName>test</finalName>
<!-- 留l在jar包中 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<!-- 开启资源打包过滤 -->
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- 打jar包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>*.xml</exclude>
<exclude>**/*.yml</exclude>
<exclude>*.txt</exclude>
<exclude>static/**</exclude>
</excludes>
<archive>
<manifest>
<!-- 指定Springboot程序启动类 -->
<mainClass>com.wei.TestApplication</mainClass>
<addClasspath>true</addClasspath>
<!-- 指定依赖的jar包相对于本程序lib的位置 -->
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 中 Class-Path 加⼊资源⽂件⽬录 -->maven打包本地jar包
<Class-Path>./resources/${project.build.finalName}/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- 该插件的作⽤是⽤于复制依赖的jar包到指定的⽂件夹⾥ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<useBaseVersion>false</useBaseVersion>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</executions>
</plugin>
<!-- 拷贝资源⽂件 -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/resources/${project.build.finalName}</outputDirectory>      <resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。