java build_error ai_generated true

无效的版本格式:依赖 com.example:lib:1.0.0-SNAPSHOT 中的 '1.0.0-SNAPSHOT '(尾部空格)。

Invalid version format: '1.0.0-SNAPSHOT ' (trailing whitespace) in dependency com.example:lib:1.0.0-SNAPSHOT

ID: java/maven-invalid-version-format

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-12-01首次发现

版本兼容性

版本状态引入弃用备注
8+ active

根因分析

版本字符串包含前导或尾部空格,Maven 版本解析器不允许。

English

The version string contains leading or trailing whitespace, which is not allowed by Maven's version parser.

generic

解决方案

  1. 100% 成功率 Trim whitespace from the version string in pom.xml
    <version>1.0.0-SNAPSHOT</version> (no trailing spaces)
  2. 95% 成功率 Use a properties file to define the version without whitespace
    <properties><lib.version>1.0.0-SNAPSHOT</lib.version></properties> and reference ${lib.version}

无效尝试

常见但无效的做法:

  1. Using a different version without whitespace but not the intended one 80% 失败

    The dependency may not exist at that version, causing a resolution error.

  2. Ignoring the error and hoping it works 99% 失败

    Maven will fail to parse the version and abort the build.