<build> <plugins> <!--定义项目的编译环境--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!--maven的测试用例插件,建议跳过。--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> <!--这个是springboot的默认编译插件,他默认会把所有的文件打包成一个jar--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <mainClass>com.xjyb.sharedelectricity.SharedelectricityApplication</mainClass> <fork>true</fork> <addResources>true</addResources> <outputDirectory>${project.build.directory}/jar</outputDirectory> </configuration> </plugin> <!-- 打JAR包 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <!-- 不打包资源文件(配置文件和依赖包分开) --> <excludes> <exclude>*.yml</exclude> <exclude>*.xml</exclude> <exclude>*.properties</exclude> <exclude>mybatis/**</exclude> <exclude>static/**</exclude> </excludes> <archive> <manifest> <addClasspath>true</addClasspath> <!-- MANIFEST.MF 中 Class-Path 加入前缀 --> <classpathPrefix>lib/</classpathPrefix> <!-- jar包不包含唯一版本标识 --> <useUniqueVersions>false</useUniqueVersions> <!--指定入口类 --> <mainClass>com.xjyb.sharedelectricity.SharedelectricityApplicationn</mainClass> </manifest> <manifestEntries> <!--MANIFEST.MF 中 Class-Path 加入资源文件目录 --> <Class-Path>./config/</Class-Path> </manifestEntries> </archive> <outputDirectory>${project.build.directory}</outputDirectory> </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> <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> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>*.yml</include> <exclude>*.xml</exclude> <include>*.properties</include> <include>mybatis/**</include> <include>static/**</include> </includes> </resource> </resources> <outputDirectory>${project.build.directory}/config</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>
SpringBoot 动静分离打包
最新推荐文章于 2025-04-17 16:49:46 发布