How to handle Maven missing artifact errors?
Asked Answered
S

1

1

I've just recently started doing Java development and I picked up Maven2 for dependency management and project task automation.

One peculiar issue I've stumbled upon, that I haven't been able to fully understand, is that for certain artifacts you need to configure exclusions for their dependencies, otherwise you get a Maven Missing artifact groupId:artifactId:version:lifecycle error. I've tried creating a Spring MVC project from the supplied STS Spring project templates and the Maven POM contained exclusions for log4j, which, when removed, would produce an error.

So what do I do when I manually add a dependency and get the missing artifact error for some of it's dependencies. Do I just jump and add them to the list of exclusions or should I be more careful about it?

And why does this happen? I'm assuming it may be perhaps that an artifact has a dependency of a certain version and another artifact has the same dependency of a different version, where both can't exist on the classpath or is it something else I'm missing?

Sesquialtera answered 22/3, 2011 at 11:50 Comment(0)
Z
3

You would configure exclusions if that particular dependency is being supplied elsewhere, either explicitly in your POM, or by another dependency.

If I got an "artifact not found" message my first thought would not be to exclude it, but to find out where it's required, then add it in the relevant scope to my POM.

Zacharie answered 22/3, 2011 at 11:58 Comment(3)
If you take log4j as an example, why can't Maven provide it's missing artifacts? I've checked the log4j POM and the 4 dependencies that have to be excluded have a compile scope set. If I manually add those dependencies as my project's POM dependencies, I also get a missing artifact error there.Polyptych
I think we'd need to see your POMs before we could give an answerZacharie
I finally read that the official repo does not redistribute Sun's binaries due to license constraints, that they rather have to be installed manually into the local Maven repo. That's to say that such errors should be resolved within an applicable scope, just like you've suggested.Polyptych

© 2022 - 2024 — McMap. All rights reserved.