maven打包插件
<build> <finalName>${jar.final.name}</finalName> <plugins> <!-- 打JAR包,不包含依赖文件;显式剔除配置文件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <!-- 剔除配置文件 --> <excludes> <exclude>*.properties</exclude> <exclude>*.yml</exclude> <exclude>*/*.properties</exclude> <exclude>*/*.yml</exclude> </excludes> <archive> <manifest> <addClasspath>true</addClasspath> <!-- MANIFEST.MF 中 Class-Path 各个依赖加入前缀 --> <!--lib文件夹内容,需要 maven-dependency-plugin插件补充--> <classpathPrefix>${output.dependence.file.path}</classpathPrefix> <!-- jar包不包含唯一版本标识 --> <useUniqueVersions>false</useUniqueVersions> <!--指定入口类 --> <mainClass>${main.class.path}</mainClass> </manifest> <manifestEntries> <!--MANIFEST.MF 中 Class-Path 加入自定义路径,多个路径用空格隔开 --> <!--此处resources文件夹的内容,需要maven-resources-plugin插件补充上--> <Class-Path>./${output.resource.file.path}</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}/${output.dependence.file.path}</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>*.properties</include> <include>*.yml</include> <include>*/*.properties</include> <include>*/*.properties</include> </includes> </resource> </resources> <outputDirectory>${project.build.directory}/${output.resource.file.path}</outputDirectory> </configuration> </execution> </executions> </plugin> <!-- spring-boot-maven-plugin可以不使用,可当做一般jar包来运行 --> <!-- spring-boot-maven-plugin可统一包内文件结构--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--重写包含依赖,包含不存在的依赖,jar里没有pom里的依赖 --> <includes> <include> <groupId>null</groupId> <artifactId>null</artifactId> </include> </includes> <outputDirectory>${project.build.directory}</outputDirectory> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <!--配置jar包特殊标识 配置后,保留原文件,生成新文件 *-run.jar --> <!--配置jar包特殊标识 不配置,原文件命名为 *.jar.original,生成新文件 *.jar --> <!--<classifier>run</classifier> --> </configuration> </execution> </executions> </plugin> <!--maven打包时,跳过测试--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build>
二:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <finalName>${jar.final.name}</finalName> <resources> <resource> <directory>src/main/java</directory> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>
本文来自博客园,作者:皮军旗,转载请注明原文链接:https://www.cnblogs.com/pijunqi/p/14830576.html