使用mvn allure:report生成Allure报告出现404错误求助
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-mavenplugin v2.8 but specifies<reportVersion>2.4.1</reportVersion>, which is way older than yourallure.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.htmldirectly 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-pluginin your terminal, then run:
Visitpython -m http.server 8080http://localhost:8080in your browser to see the report. - Node.js: Install
http-serverglobally first (npm install -g http-server), then run:
Use the URL provided in the terminal to access the report.http-server target/site/allure-maven-plugin
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
- Update your pom.xml with the corrected Allure plugin configuration.
- Run
mvn clean testto generate freshallure-results. - Run
mvn allure:reportto build the static report. - Serve the report via a local HTTP server and check if it loads correctly.
内容的提问来源于stack exchange,提问作者zjadarka

