19

I have an installed dependency in my local repository. The remote repository where the dependency came from is now down for some reason. When I try to compile the project Maven says that it can't resolve dependency. But why???

2 Answers 2

27

When you have these error, simply clean the _remote.repositories that indicate maven where the dependency comes from. You will find this file for each artifact inside your M2_REPO.

3
  • 3
    I tried many approaches with no luck, this is the solution finally worked. Thanks. Feb 14, 2017 at 10:43
  • Life is better when shared!
    – bob
    Sep 12, 2018 at 15:57
  • Was struggling with an old project on a new machine with many legacy jars. Your tip helped. Just deleted all _remote.repositories files and any file with lastUpdated in the name and it all worked perfectly! Jan 3 at 4:24
19

Maven will compare the local POM's timestamp (stored in a repository's maven-metadata file) to the remote. When maven does this depends on the updatePolicy that can be defined in your settings xml.

Either set this to never (discouraged) or skip this check (only when a remote repository appears to be down) by using the -o option (offline); then maven will not check remote repositories.

5
  • 4
    I have tried to put it in offline mode, but in that case it says, that as it is in offline mode it cant get dependency Mar 12, 2011 at 20:06
  • 1
    By the way, I have solved (perhaps project is built and normally deployed) that problem by using install:install-file plugin Mar 12, 2011 at 21:42
  • I'm trying to do some dev with eclipse dependencies, and because I can't find these jars, I have installed them locally and the offline option help me a lot. Thanks. Dec 22, 2013 at 16:59
  • @michael nesterenko thanks, it also worked for me. It seems that it cached previous failure to fetch it from repository and ignored local file after that no matter what, using install plugin helped with that.
    – user158037
    Mar 15, 2016 at 9:49
  • I tried both updatePolicy and --offline methods. I still get Cannot access <XXX> in offline mode and the artifact <YYY> has not been downloaded from it before or messages mentioning missing dependency. It worked after I removed the _remote.repositories files of maven cache.
    – ajkret
    Feb 7 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.