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

如何修复Maven“存储Mojo状态时出错”问题?

Maven编译报错:无法存储mojo状态(inputFiles.lst找不到)

环境信息

Windows 10系统,计划基于Java 20构建项目,当前Maven/Java环境如下:

PS H:\Documents\auto-testing> mvn --version
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: H:\Documents\Maven\apache-maven-3.9.5
Java version: 19.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Microsoft\jdk-19.0.2
Default locale: en_CA, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

报错详情

执行mvn compile时出现如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project TRTesting: Error while storing the mojo status: H:\Documents\auto-testing\target\maven-status\maven-compiler-plugin\compile\default-compile\inputFiles.lst -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project TRTesting: Error while storing the mojo status
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    ...
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

已尝试的操作

  • 中断一次构建流程后问题突然出现
  • 确认拥有项目目录的全部权限
  • 执行过mvn clean删除target目录,编译时会自动重建,但问题依旧
  • 已将Maven升级至最新版本3.9.5

项目pom.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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.truckright</groupId>
    <artifactId>TRTesting</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.version>20</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Cucumber -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.14.0</version>
        </dependency>
    
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>7.14.0</version>
            <scope>test</scope>
        </dependency>

        <!-- TestNG -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.8.0</version>
            <scope>test</scope>
        </dependency>

        <!-- Selenide -->
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>7.0.1</version>
            <scope>test</scope>
        </dependency>

        <!-- Selenium WebDriver Management -->
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.6.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <systemPropertyVariables>
                        <!-- This lets us set the tags marking scenarios/features to be run.
                             See https://cucumber.io/docs/cucumber/configuration/?lang=java#profiles
                             It can also be done from the Maven command line, and in the RunCucumberTest
                             method.
                        <cucumber.filter.tags>@change-language</cucumber.filter.tags>
                        -->
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

解决方案尝试

  • 彻底清理target目录:手动删除整个target文件夹(包括可能存在的隐藏文件),再执行mvn compile。有时mvn clean无法完全清理残留的锁定文件。
  • 对齐Java版本:pom中配置的Java版本是20,但实际环境用的是19。要么修改pom里的java.version为19,要么安装Java20并配置环境变量让Maven使用该版本,版本不匹配可能导致文件生成异常。
  • 强制重新构建:执行mvn clean compile -U,-U参数会强制更新快照依赖,同时重新生成所有maven状态文件。
  • 升级编译器插件:将maven-compiler-plugin版本升级到最新稳定版(比如3.12.1),旧版本可能和Maven 3.9.5/Java环境存在兼容性问题,修改pom中对应插件的version即可。
  • 释放文件锁:关闭可能锁定target目录的程序(比如杀毒软件、文件资源管理器、IDE进程),或重启电脑后再尝试构建。Windows下文件锁容易导致Maven无法写入文件。
  • 清理插件缓存:删除Maven本地仓库中maven-compiler-plugin的缓存目录(路径一般为~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0),重新执行构建让Maven重新下载插件。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 13:14:54