java build_error ai_generated true

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

ID: java/maven-invalid-version-format

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-12-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8+ active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

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

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

  2. Ignoring the error and hoping it works 99% fail

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