- pom.xml: - 添加finalName配置去除版本号 - maven-jar-plugin排除资源文件 - 禁用spring-boot-maven-plugin repackage - 各服务移除冗余的plugin配置 - assembly.xml: - 主JAR放根目录(仅服务代码) - lib目录放依赖JAR - start.sh: - 支持java -cp classpath模式启动 - 从service.properties读取MAIN_CLASS - 向后兼容fat jar模式 - service.properties: - 所有服务添加MAIN_CLASS配置 优势: - 主JAR从131MB缩小到103KB - 多服务部署可共享lib目录 - 资源文件外置便于修改
147 lines
5.3 KiB
XML
147 lines
5.3 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
<modelVersion>4.0.0</modelVersion>
|
||
|
||
<!-- 作为整个资金服务平台的父工程(聚合 + 继承) -->
|
||
<parent>
|
||
<groupId>org.springframework.boot</groupId>
|
||
<artifactId>spring-boot-starter-parent</artifactId>
|
||
<version>3.2.0</version>
|
||
<relativePath/>
|
||
</parent>
|
||
|
||
<groupId>com.fundplatform</groupId>
|
||
<artifactId>fundplatform</artifactId>
|
||
<version>0.0.1-SNAPSHOT</version>
|
||
<packaging>pom</packaging>
|
||
|
||
<name>fundplatform</name>
|
||
<description>Fund Service Platform - Parent</description>
|
||
|
||
<modules>
|
||
<module>fund-common</module>
|
||
<module>fund-gateway</module>
|
||
<module>fund-sys</module>
|
||
<module>fund-cust</module>
|
||
<module>fund-proj</module>
|
||
<module>fund-req</module>
|
||
<module>fund-exp</module>
|
||
<module>fund-receipt</module>
|
||
<module>fund-report</module>
|
||
<module>fund-file</module>
|
||
</modules>
|
||
|
||
<properties>
|
||
<java.version>21</java.version>
|
||
<spring-cloud.version>2023.0.0</spring-cloud.version>
|
||
<spring-cloud-alibaba.version>2023.0.0.0-RC1</spring-cloud-alibaba.version>
|
||
</properties>
|
||
|
||
<dependencyManagement>
|
||
<dependencies>
|
||
<!-- Spring Cloud -->
|
||
<dependency>
|
||
<groupId>org.springframework.cloud</groupId>
|
||
<artifactId>spring-cloud-dependencies</artifactId>
|
||
<version>${spring-cloud.version}</version>
|
||
<type>pom</type>
|
||
<scope>import</scope>
|
||
</dependency>
|
||
<!-- Spring Cloud Alibaba -->
|
||
<dependency>
|
||
<groupId>com.alibaba.cloud</groupId>
|
||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||
<version>${spring-cloud-alibaba.version}</version>
|
||
<type>pom</type>
|
||
<scope>import</scope>
|
||
</dependency>
|
||
</dependencies>
|
||
</dependencyManagement>
|
||
|
||
<!-- 公共依赖 - 所有模块都需要的依赖 -->
|
||
<dependencies>
|
||
<!-- Spring Boot Actuator - 健康检查和监控端点 -->
|
||
<dependency>
|
||
<groupId>org.springframework.boot</groupId>
|
||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||
</dependency>
|
||
|
||
<!-- Micrometer Prometheus - Prometheus 监控指标暴露 -->
|
||
<dependency>
|
||
<groupId>io.micrometer</groupId>
|
||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||
</dependency>
|
||
</dependencies>
|
||
|
||
<!-- 项目内自定义 Maven 仓库配置,避免依赖外部 settings.xml 中的私服配置 -->
|
||
<repositories>
|
||
<!-- 官方中央仓库 -->
|
||
<repository>
|
||
<id>central</id>
|
||
<url>https://repo1.maven.org/maven2</url>
|
||
<releases>
|
||
<enabled>true</enabled>
|
||
</releases>
|
||
<snapshots>
|
||
<enabled>false</enabled>
|
||
</snapshots>
|
||
</repository>
|
||
</repositories>
|
||
|
||
<pluginRepositories>
|
||
<pluginRepository>
|
||
<id>central</id>
|
||
<url>https://repo1.maven.org/maven2</url>
|
||
<releases>
|
||
<enabled>true</enabled>
|
||
</releases>
|
||
<snapshots>
|
||
<enabled>false</enabled>
|
||
</snapshots>
|
||
</pluginRepository>
|
||
</pluginRepositories>
|
||
|
||
<!-- 公共构建配置 - 所有服务模块继承 -->
|
||
<build>
|
||
<!-- 输出文件名不带版本号 -->
|
||
<finalName>${project.artifactId}</finalName>
|
||
<plugins>
|
||
<!-- Maven JAR Plugin - 打包普通JAR(排除资源文件) -->
|
||
<plugin>
|
||
<groupId>org.apache.maven.plugins</groupId>
|
||
<artifactId>maven-jar-plugin</artifactId>
|
||
<version>3.3.0</version>
|
||
<configuration>
|
||
<archive>
|
||
<manifest>
|
||
<addClasspath>true</addClasspath>
|
||
<classpathPrefix>lib/</classpathPrefix>
|
||
</manifest>
|
||
</archive>
|
||
<!-- 排除资源文件,资源文件通过assembly打包到conf目录 -->
|
||
<excludes>
|
||
<exclude>**/*.yml</exclude>
|
||
<exclude>**/*.yaml</exclude>
|
||
<exclude>**/*.properties</exclude>
|
||
<exclude>**/*.xml</exclude>
|
||
<exclude>**/*.json</exclude>
|
||
</excludes>
|
||
</configuration>
|
||
</plugin>
|
||
|
||
<!-- Spring Boot Maven Plugin - 禁用repackage,生成普通JAR -->
|
||
<plugin>
|
||
<groupId>org.springframework.boot</groupId>
|
||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||
<configuration>
|
||
<finalName>${project.artifactId}</finalName>
|
||
<!-- 禁用repackage,不生成fat jar -->
|
||
<skip>true</skip>
|
||
</configuration>
|
||
</plugin>
|
||
</plugins>
|
||
</build>
|
||
</project>
|