yxh
昨天 fce96ef468291fb9a0e6a4d34ab371315e9485d4
jh-server/pom.xml
@@ -134,18 +134,52 @@
            <version>${openfeign.version}</version>
        </dependency>
<!--
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
-->
    </dependencies>
    <build>
        <!-- 设置构建的 jar 包名 -->
        <finalName>${project.artifactId}</finalName>
        <!--
            合并部署:把 ecg_web 的前端构建产物打进 jar。
            · 目标目录选 META-INF/resources/frontend 而非 static:
              META-INF/resources 是 Servlet 3.0 标准静态资源目录,Spring Boot
              默认会扫描;额外加一层 frontend/ 前缀,便于后端用
              addResourceHandlers 精确控制"哪些 URL 交给前端",
              不影响后端已有的 /doc.html、/druid/**、/profile/** 等路径。
              见 cn.lihu.jh.server.ecg.FrontendResourceConfig。
            · 产物目录由 profile 注入的 env.VITE_OUT_DIR 决定,
              默认 dist-merged(对应 ecg_web 的 `pnpm build:merged`)。
            · 注意:本模块【不】引入 frontend-maven-plugin。
              前端构建请在部署前单独执行(cd ecg_web && pnpm build:merged),
              避免后端构建强依赖 node/pnpm,也避免构建机需要外网下载 node。
        -->
        <resources>
            <!-- 保留原有的后端资源(application*.yaml、logback-spring.xml 等) -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <!-- 新增:前端产物 -->
            <resource>
                <directory>${project.basedir}/../../ecg_web/${env.VITE_OUT_DIR}</directory>
                <targetPath>META-INF/resources/frontend</targetPath>
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <!-- 打包 -->
            <plugin>
@@ -163,4 +197,31 @@
        </plugins>
    </build>
    <!--
        前端产物目录的选择。env.VITE_OUT_DIR 会被上面 <resources> 引用。
        · frontend-merged(默认):使用 ecg_web 执行 `pnpm build:merged` 产出的
          dist-merged,对应"前端打进 jar、与后端同源"的合并部署模式。
        · frontend-prod:回退到原有的 dist-prod。若前端仍由 nginx 独立托管
          (即不做合并部署),用 -P frontend-prod 激活此 profile 即可,
          此时 jar 内不含前端,行为与改造前一致。
    -->
    <profiles>
        <profile>
            <id>frontend-merged</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <env.VITE_OUT_DIR>dist-merged</env.VITE_OUT_DIR>
            </properties>
        </profile>
        <profile>
            <id>frontend-prod</id>
            <properties>
                <env.VITE_OUT_DIR>dist-prod</env.VITE_OUT_DIR>
            </properties>
        </profile>
    </profiles>
</project>