springboot的jar分开打包

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4    <modelVersion>4.0.0</modelVersion>
  5    <groupId>com.test</groupId>
  6    <artifactId>owl-sv</artifactId>
  7    <version>2.2.0</version>
  8    <packaging>jar</packaging>
  9 
 10    <name>test-package</name>
 11    <description>jar包分开打包配置</description>
 12    <parent>
 13       <groupId>org.springframework.boot</groupId>
 14       <artifactId>spring-boot-starter-parent</artifactId>
 15       <version>2.2.5.RELEASE</version>
 16       <relativePath />
 17    </parent>
 18    <properties>
 19       <!-- 项目打包地址 -->
 20       <project.bulid.fileName>${project.artifactId}-${project.version}</project.bulid.fileName>
 21       <project.release.directory>C:\Users\test\Desktop\test</project.release.directory>
 22       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 23       <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 24       <java.version>1.8</java.version>
 25       
 26    </properties>
 27    <dependencies>
 28        
 29     </dependencies>
 30    <build>
 31       <plugins>
 32          <plugin>
 33             <groupId>org.springframework.boot</groupId>
 34             <artifactId>spring-boot-maven-plugin</artifactId>
 35             <configuration>
 36                <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
 37             </configuration>
 38          </plugin>
 39          <!-- 打jar包时忽略配置文件 -->
 40          <plugin>
 41             <groupId>org.apache.maven.plugins</groupId>
 42             <artifactId>maven-jar-plugin</artifactId>
 43             <configuration>
 44                <excludes>
 45                   <exclude>**/*.yml</exclude>
 46                   <exclude>**/*.xml</exclude>
 47                </excludes>
 48             </configuration>
 49          </plugin>
 50          <plugin>
 51             <groupId>org.springframework.boot</groupId>
 52             <artifactId>spring-boot-maven-plugin</artifactId>
 53             <configuration>
 54                <layout>ZIP</layout>
 55                <includes>
 56                   <include>
 57                      <groupId>non-exists</groupId>
 58                      <artifactId>non-exists</artifactId>
 59                   </include>
 60                </includes>
 61             </configuration>
 62             <executions>
 63                <execution>
 64                   <goals>
 65                      <goal>repackage</goal>
 66                   </goals>
 67                </execution>
 68             </executions>
 69          </plugin>
 70          <!-- copy资源文件 -->
 71          <plugin>
 72             <artifactId>maven-antrun-plugin</artifactId>
 73             <executions>
 74                <execution>
 75                   <phase>package</phase>
 76                   <goals>
 77                      <goal>run</goal>
 78                   </goals>
 79                   <configuration>
 80                      <tasks>
 81                         <mkdir dir="${project.release.directory}"/>
 82                         <mkdir dir="${project.release.directory}/logs"/>
 83                         <copy todir="${project.release.directory}" overwrite="true" >
 84                            <fileset dir="shell">
 85                            </fileset>
 86                         </copy>
 87                         <copy todir="${project.release.directory}/sql" overwrite="true" >
 88                            <fileset dir="sql">
 89                            </fileset>
 90                         </copy>
 91                         <copy todir="${project.release.directory}/config" overwrite="true" >
 92                            <fileset dir="src/main/resources">
 93                            </fileset>
 94                         </copy>
 95                         <copy file="target/${project.bulid.fileName}.jar" todir="${project.release.directory}/libs" overwrite="true" >
 96                         </copy>
 97                      </tasks>
 98                   </configuration>
 99                </execution>
100             </executions>
101          </plugin>
102          <!-- 将依赖拷贝到最终libs目录 -->
103          <plugin>
104             <groupId>org.apache.maven.plugins</groupId>
105             <artifactId>maven-dependency-plugin</artifactId>
106             <executions>
107                <execution>
108                   <id>copy-dependencies</id>
109                   <phase>package</phase>
110                   <goals>
111                      <goal>copy-dependencies</goal>
112                   </goals>
113                   <configuration>
114                      <!-- 依赖包输出目录,不打进jar包里 -->
115                      <outputDirectory>${project.release.directory}/libs</outputDirectory>
116                      <excludeTransitive>false</excludeTransitive>
117                      <stripVersion>false</stripVersion>
118                      <includeScope>runtime</includeScope>
119                      <excludeArtifactIds>servlet-api</excludeArtifactIds>
120                   </configuration>
121                </execution>
122             </executions>
123          </plugin>
124       </plugins>
125    </build>
126    <repositories>
127       <!--阿里云镜像仓库-->
128       <repository>
129          <id>public</id>
130          <name>aliyun nexus</name>
131          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
132          <releases>
133             <enabled>true</enabled>
134          </releases>
135       </repository>
136    </repositories>
137    <pluginRepositories>
138       <pluginRepository>
139          <id>public</id>
140          <name>aliyun nexus</name>
141          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
142          <releases>
143             <enabled>true</enabled>
144          </releases>
145          <snapshots>
146             <enabled>false</enabled>
147          </snapshots>
148       </pluginRepository>
149    </pluginRepositories>
150 </project>

 

上一篇:Kettle on MaxCompute使用指南


下一篇:2021-08-07