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

使用mvn allure:report生成Allure报告出现404错误求助

Fixing 404 Error When Opening Allure Report Generated by mvn allure:report

Hey, let's break down why you're seeing that 404 error with mvn allure:report while mvn allure:serve works perfectly. Here's what's likely going on and how to fix it:

Possible Causes

  • Version Mismatch Between Allure Maven Plugin and Report: Your pom uses allure-maven plugin v2.8 but specifies <reportVersion>2.4.1</reportVersion>, which is way older than your allure.version (2.13.6). This version conflict can mess up how static resources are generated and referenced.
  • Local File Path Issues with Static Resources: When you open the generated index.html directly in a browser, it uses local file system paths to load CSS/JS assets. Allure's static report relies on relative paths, which don't always work well with direct file access due to browser security policies.
  • Inconsistent Allure Results Directory Configuration: Even though you defined allure.directory, there might be a mismatch between where the Surefire plugin writes results and where the Allure plugin reads them.

Step-by-Step Fixes

1. Align Allure Versions & Remove Conflicting Report Version

Your core Allure dependency is v2.13.6, so update the Allure Maven plugin to match and remove the outdated reportVersion setting (the plugin will auto-use the compatible report version):

<plugin>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-maven</artifactId>
    <version>2.13.6</version> <!-- Match your allure.version -->
    <!-- Delete the <reportVersion>2.4.1</reportVersion> line -->
</plugin>

This eliminates version conflicts that could break resource loading.

2. Ensure Consistent Results Directory Configuration

Make sure the Allure Maven plugin reads from the same directory where Surefire writes results. Add this configuration to the allure-maven plugin:

<plugin>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-maven</artifactId>
    <version>2.13.6</version>
    <configuration>
        <resultsDirectory>${allure.directory}</resultsDirectory> <!-- Match your defined directory -->
    </configuration>
</plugin>

This ensures the report generator can find all your test result data.

3. Serve the Static Report via a Local HTTP Server

Directly opening the HTML file won't work for Allure's static reports—browsers block some resource loads from local files. Use a simple HTTP server instead:

  • Python: Navigate to target/site/allure-maven-plugin in your terminal, then run:
    python -m http.server 8080
    
    Visit http://localhost:8080 in your browser to see the report.
  • Node.js: Install http-server globally first (npm install -g http-server), then run:
    http-server target/site/allure-maven-plugin
    
    Use the URL provided in the terminal to access the report.

4. Clean & Rebuild From Scratch

Old build artifacts can cause weird issues. Run these commands to start fresh:

mvn clean test allure:report

This clears old results, re-runs tests, and generates a new report.

Verification Steps

  1. Update your pom.xml with the corrected Allure plugin configuration.
  2. Run mvn clean test to generate fresh allure-results.
  3. Run mvn allure:report to build the static report.
  4. Serve the report via a local HTTP server and check if it loads correctly.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 17:32:40