You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

maven-project-info-reports-plugin与maven-site-plugin共存时index.html被覆盖问题求助

解决方案

问题原因

自定义site.xml后,Maven Site插件会完全使用你定义的导航结构,不再自动加载默认的项目信息报告菜单(如Project Information、Project Reports),同时默认生成的项目概览index.html会被自定义站点的首页覆盖。

具体修复步骤

1. 修改site.xml,引入默认报告菜单并指定首页

更新src/site/site.xml,加入默认项目信息和报告菜单的引用,同时设置首页为原项目信息概览:

<project xmlns="http://maven.apache.org/SITE/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 http://maven.apache.org/xsd/site-2.0.0.xsd"
         name="Content">

    <skin>
        <groupId>org.apache.maven.skins</groupId>
        <artifactId>maven-fluido-skin</artifactId>
        <version>2.0.0-M6</version>
    </skin>

    <!-- 指定首页为原项目信息概览页面 -->
    <index ref="project-info"/>

    <body>
        <!-- 自定义Overview菜单保留不变 -->
        <menu name="Overview">
            <item name="Another Page" href="sample.html" />
        </menu>

        <!-- 引入默认的项目信息菜单(包含项目描述、依赖、许可证等原报告) -->
        <menu ref="project-info"/>

        <!-- 引入默认的项目报告菜单(包含Jacoco、Checkstyle、Javadoc等你配置的报告) -->
        <menu ref="reports"/>
    </body>

</project>

2. 验证效果

执行mvn install后,生成的站点会满足以下要求:

  • index.html保留原项目信息概览内容,不会被覆盖
  • 左侧菜单同时显示自定义的Overview(包含你的sample.html页面)、默认的Project Information和Project Reports菜单
  • 所有原项目信息报告和自定义文档都可正常访问

内容的提问来源于stack exchange,提问作者raedma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 18:24:53