Missing artifact error in Maven

2019-01-28 16:55发布

问题:

I get a missing artifact error during Maven build because one of the dependencies declares it's parent artifact using a property for the version. Now the property itself is declared in the parent pom and my project's build fails giving this error:

[ERROR] Failed to execute goal on project abc: Unable to get dependency
information for xyz:pqr:jar:SNAPSHOT: Failed to process POM for 
xyz:pqr:jar:SNAPSHOT: Non-resolvable parent POM xyz:pqr-parent:${someversion}
for xyz:pqr:${someversion}: Failed to resolve POM for 
xyz:pqr-parent:${someversion} due to Missing:
----------
1) xyz:pqr-parent:pom:${someversion}
----------
1 required artifact is missing.

for artifact:
xyz:pqr-parent:pom:${someversion}

I have verified that the artifacts are present in correct location in the repository.

Is there a way to specify the value of someversion property used in the dependency pom? If not, how should the dependency pom be changed to resolve the error?

回答1:

I get a missing artifact error during Maven build because one of the dependencies declares it's parent artifact using a property for the version. Now the property itself is declared in the parent pom and my project's build fails giving this error (...)

This is a chicken and egg problem: you can't get the version of the parent to use from the parent.

Is there a way to specify the value of someversion property used in the dependency pom?

AFAIK, this is not possible, properties in project.parent.version do NOT get substituted. You might want to check MNG-624 (and vote for it) and related issues.

If not, how should the dependency pom be changed to resolve the error?

Use an "hard-coded" version in project.parent.version.