<build>
<finalName>test</finalName>
<!-- 留mapper.xml在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 加入资源文件目录 -->
<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>
</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>
spring-boot 使用maven打包独立配置资源文件pom.xml 备忘
最新推荐文章于 2024-09-26 09:47:55 发布