8181 <!-- 设置构建的 jar 包名 -->
8282 <finalName >${project.parent.name} </finalName >
8383 <plugins >
84- <!-- Maven 打包插件 -->
84+ <!-- Spring Boot 可执行 JAR 打包插件 -->
8585 <plugin >
86- <groupId >org.apache.maven.plugins </groupId >
87- <artifactId >maven-jar -plugin</artifactId >
86+ <groupId >org.springframework.boot </groupId >
87+ <artifactId >spring-boot-maven -plugin</artifactId >
8888 <configuration >
89- <!-- 排除配置文件 -->
90- <excludes >
91- <exclude >${config-path} </exclude >
92- <exclude >db/</exclude >
93- <exclude >templates/</exclude >
94- <exclude >logback-spring.xml</exclude >
95- </excludes >
96- <archive >
97- <manifest >
98- <mainClass >${main-class} </mainClass >
99- <!-- 为 MANIFEST.MF 中的 Class-Path 加入依赖 jar 目录前缀 -->
100- <classpathPrefix >../${lib-path} </classpathPrefix >
101- <addClasspath >true</addClasspath >
102- <!-- jar 包不包含唯一版本标识 -->
103- <useUniqueVersions >false</useUniqueVersions >
104- </manifest >
105- <manifestEntries >
106- <!-- 为 MANIFEST.MF 中的 Class-Path 加入配置文件目录前缀 -->
107- <Class-Path >../${config-path} </Class-Path >
108- </manifestEntries >
109- </archive >
110- <outputDirectory >${project.build.directory} /app/${bin-path} </outputDirectory >
89+ <includeSystemScope >true</includeSystemScope >
90+ <skip >${skip.boot.repackage} </skip >
11191 </configuration >
112- </plugin >
113- <!-- 拷贝依赖 jar -->
114- <plugin >
115- <groupId >org.apache.maven.plugins</groupId >
116- <artifactId >maven-dependency-plugin</artifactId >
117- <executions >
118- <execution >
119- <id >copy-dependencies</id >
120- <phase >package</phase >
121- <goals >
122- <goal >copy-dependencies</goal >
123- </goals >
124- <configuration >
125- <outputDirectory >${project.build.directory} /app/${lib-path} </outputDirectory >
126- </configuration >
127- </execution >
128- </executions >
129- </plugin >
130- <!-- 拷贝配置文件 -->
131- <plugin >
132- <groupId >org.apache.maven.plugins</groupId >
133- <artifactId >maven-resources-plugin</artifactId >
13492 <executions >
13593 <execution >
136- <id >copy-resources</id >
137- <phase >package</phase >
13894 <goals >
139- <goal >copy-resources </goal >
95+ <goal >repackage </goal >
14096 </goals >
141- <configuration >
142- <resources >
143- <resource >
144- <directory >src/main/resources/${config-path} </directory >
145- </resource >
146- <resource >
147- <directory >src/main/resources</directory >
148- <includes >
149- <include >db/</include >
150- <include >templates/</include >
151- <include >logback-spring.xml</include >
152- </includes >
153- </resource >
154- </resources >
155- <outputDirectory >${project.build.directory} /app/${config-path} </outputDirectory >
156- </configuration >
15797 </execution >
15898 </executions >
15999 </plugin >
160100 </plugins >
161101 </build >
102+
103+ <profiles >
104+ <!-- 默认 Spring Boot 胖包 模式 -->
105+ <profile >
106+ <id >fat_jar</id >
107+ <properties >
108+ <skip .boot.repackage>false</skip .boot.repackage>
109+ </properties >
110+ </profile >
111+
112+ <!-- 瘦包 模式(可执行 JAR + lib + config) -->
113+ <profile >
114+ <id >slim_jar</id >
115+ <!-- 默认-->
116+ <activation >
117+ <activeByDefault >true</activeByDefault >
118+ </activation >
119+ <properties >
120+ <skip .boot.repackage>true</skip .boot.repackage>
121+
122+ <!-- 路径变量 -->
123+ <lib-path >lib/</lib-path >
124+ <config-path >config/</config-path >
125+ <bin-path >bin/</bin-path >
126+ <!-- 启动类 -->
127+ <main-class >top.continew.admin.ContiNewAdminApplication</main-class >
128+ </properties >
129+ <build >
130+ <plugins >
131+ <!-- 分离打包 JAR(不包含依赖) -->
132+ <plugin >
133+ <groupId >org.apache.maven.plugins</groupId >
134+ <artifactId >maven-jar-plugin</artifactId >
135+ <configuration >
136+ <!-- 排除配置文件 -->
137+ <excludes >
138+ <exclude >${config-path} </exclude >
139+ <exclude >db/</exclude >
140+ <exclude >templates/</exclude >
141+ <exclude >logback-spring.xml</exclude >
142+ </excludes >
143+ <archive >
144+ <manifest >
145+ <mainClass >${main-class} </mainClass >
146+ <!-- 为 MANIFEST.MF 中的 Class-Path 加入依赖 jar 目录前缀 -->
147+ <classpathPrefix >../${lib-path} </classpathPrefix >
148+ <addClasspath >true</addClasspath >
149+ <!-- jar 包不包含唯一版本标识 -->
150+ <useUniqueVersions >false</useUniqueVersions >
151+ </manifest >
152+ <manifestEntries >
153+ <!-- 为 MANIFEST.MF 中的 Class-Path 加入配置文件目录前缀 -->
154+ <Class-Path >../${config-path} </Class-Path >
155+ </manifestEntries >
156+ </archive >
157+ <outputDirectory >${project.build.directory} /app/${bin-path} </outputDirectory >
158+ </configuration >
159+ </plugin >
160+
161+ <!-- 拷贝依赖 jar -->
162+ <plugin >
163+ <groupId >org.apache.maven.plugins</groupId >
164+ <artifactId >maven-dependency-plugin</artifactId >
165+ <executions >
166+ <execution >
167+ <id >copy-dependencies</id >
168+ <phase >package</phase >
169+ <goals >
170+ <goal >copy-dependencies</goal >
171+ </goals >
172+ <configuration >
173+ <outputDirectory >${project.build.directory} /app/${lib-path} </outputDirectory >
174+ </configuration >
175+ </execution >
176+ </executions >
177+ </plugin >
178+
179+ <!-- 拷贝配置文件 -->
180+ <plugin >
181+ <groupId >org.apache.maven.plugins</groupId >
182+ <artifactId >maven-resources-plugin</artifactId >
183+ <executions >
184+ <execution >
185+ <id >copy-resources</id >
186+ <phase >package</phase >
187+ <goals >
188+ <goal >copy-resources</goal >
189+ </goals >
190+ <configuration >
191+ <resources >
192+ <resource >
193+ <directory >src/main/resources/${config-path} </directory >
194+ </resource >
195+ <resource >
196+ <directory >src/main/resources</directory >
197+ <includes >
198+ <include >db/</include >
199+ <include >templates/</include >
200+ <include >logback-spring.xml</include >
201+ </includes >
202+ </resource >
203+ </resources >
204+ <outputDirectory >${project.build.directory} /app/${config-path} </outputDirectory >
205+ </configuration >
206+ </execution >
207+ </executions >
208+ </plugin >
209+
210+ </plugins >
211+ </build >
212+ </profile >
213+ </profiles >
162214</project >
0 commit comments