98

I created a new simple Maven project in a new Workspace.

When I open the pom.xml's Dependencies view in Eclipse editor, and I choose Add.. dependency, there's no search results no matter what search criteria I input in the search fields:

It instantly give me, for example, Results for 'spring' (0).

In my other workspace, with my existing projects I don't have this problem.

Is there a way to fix that ?

palacsint
  • 28,416
  • 10
  • 82
  • 109
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
  • 3
    I believe there is solution in following link: stackoverflow.com/questions/7065478/classic-error-unable-to-update-index-for-centralhttp-repo1-maven-org-maven2 [1]: http://stackoverflow.com/questions/7065478/classic-error-unable-to-update-index-for-centralhttp-repo1-maven-org-maven2 – Eric Jun 25 '14 at 03:56

8 Answers8

195

Eclipse artifact searching depends on repository's index file. It seems you did not download the index file.

Go to Window -> Prefrences -> Maven and check "Download repository index updates on start". Restart Eclipse and then look at the progress view. An index file should be downloading.

After downloading completely, artifact searching will be ready to use.

Maven Settings

UPDATE You also need to rebuild your Maven repository index in 'maven repository view'.

In this view , open 'Global Repositories', right-click 'central', check 'Full Index Enable', and then, click 'Rebuild Index' in the same menu.

A 66M index file will be downloaded.

Maven Repositories -> Rebuild Index

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Xiujun Ma
  • 2,574
  • 1
  • 14
  • 19
9

In your eclipse, go to Windows -> Preferences -> Maven Preferences Maven Screenshot Tick the option "Download repository index updates on startup". You may want to restart the eclipse.

Also go to Windows -> Show view -> Other -> Maven -> Maven repositories Maven Repository View Screenshot

On Maven repositories panel, Expand Global repositories then Right click on Central repositories and check "Full index enabled" option and then click on "Rebuild index".

Full Index Screenshot

Mirwise Khan
  • 1,317
  • 17
  • 25
Hetal Rachh
  • 1,393
  • 1
  • 17
  • 23
  • 1
    How does your answer add anything at all to the previously accepted answer by Xiujun Ma? It's as though you have copied that answer but reworded it. Even the screen shots in your answer are almost identical to those for the accepted answer! – skomisa Jul 26 '18 at 00:06
  • @skomisa I haven't copied the answer at all. I answered this when I actually faced this issue. Also the screenprints are from my work. Copying and pasting answers doesn't make sense on stackoverflow. And if I would copy paste it, I would have answered thousands of questions by now which I haven't yet. – Hetal Rachh Jul 26 '18 at 05:58
  • 4
    OK, but your answer is only repeating the information that was provided in the accepted answer. – skomisa Jul 26 '18 at 06:04
4

You can get this result if you are inside a corporate proxy and the new project isn't pointing to the correct settings.xml file with the proxy credentials.

You can also get this if you are using Maven proxy (Nexus, for example) and the index into the proxy is messed up somehow. I don't know a way to describe how to fix this. Fool around with it or call the one who set up the Maven proxy.

You can also get this if the new workspace hasn't yet downloaded the index either from Maven central or from the proxy. (This is the best one as you just have to wait a while and it will work itself out.)

Lee Meador
  • 12,829
  • 2
  • 36
  • 42
  • actually I have the two workspaces open (in two different eclipses), in one of them it works and not the other, so it can't be a proxy or internet connection problem. And there's no setting.xml file in neither workspaces.. I think you might be right about the downloaded index, but I don't know how to download it (i've been having this problem since yesterday so it's useless to wait) – Majid Laissi Dec 27 '12 at 18:59
  • 1
    I'm using MyEclipse and the preferences may be different than yours. But I have a button you get to with window > preferences > MyEclipse > Maven4MyEclipse > User Settings. The button is labelled "Reindex" and if you click it, it might help. There is a picture and more info here: [(click)](http://stackoverflow.com/questions/10235374/how-to-change-maven-local-repository-in-eclipse) – Lee Meador Dec 27 '12 at 19:16
  • BTW - settings.xml is a file found in the .m2 folder in your user folder. (Windows 7 is c:\Users\YourName\.m2, Linux is ~/.m2) and it can hold global information for multiple workspaces. That same preferences page lets you select it. – Lee Meador Dec 27 '12 at 19:19
  • Thank you for your time. I have tried that with no luck, but Reindex would only reindex my local maven repository (libs I already have) ? And for the settings.xml file, it doesn't exist in neither workspace, (Eclipse preferences / user settings references `C:\Users\XX\.m2\settings.xml` and says `User settings file doesn't exist`) and it's the same thing for both workspaces, so I guess it's not important. – Majid Laissi Dec 27 '12 at 19:23
  • info [http://maven.apache.org/settings.html](http://maven.apache.org/settings.html) on what is in the file. As long as no proxy, no passwords and everything you need is in Maven Central, you can get by without one. – Lee Meador Dec 28 '12 at 01:26
  • Which Maven Eclipse plugin are you using? – Lee Meador Dec 28 '12 at 01:27
4

For me for this issue worked to:

  • remove ~/.m2
  • enable "Full Index Enabled" in maven repository view on central repository
  • "Rebuild Index" on central maven repository

After eclipse restart everything worked well.

Pavel
  • 141
  • 3
3

The maven add dependency is actually from the maven indexes. If the indexes is up to date, the result should be from there.

If you go to the maven repository, then select global repository, you should see a central ... tab, and select that, there should be a list of folders, and you should be able to see all the indexes from there. If not, then it means you didn't get the full index, then you can right click that and enable full index.

Another thing I annoyed me most is even I did everything, it still not showing anything when I type "spring". This is actually where I did wrong. If you just type some additional text "springframework", BOOM, the result is there.

Tian Hu
  • 31
  • 1
1

I have the same problem. None of the options suggested above worked for me. However I find, that if I lets say manually add groupid/artifact/version for org.springframework.spring-core version 4.3.4.RELEASE and save the pom.xml, the dependencies download automatically and the search works for the jars already present in the repository. However if I now search for org.springframework.spring-context , which isnt in the current dependencies, this search still doesn't work.

arpi
  • 31
  • 2
0

Use https://search.maven.org/ manually with the prefix fc: to search for class names. Both Netbeans and Eclipse seem to be too stupid to use that search interface and the gigabytes of downloaded repository indexes seem to not contain any class information. Total waste of disk space. Those IDE projects are so badly maintained lately, I wish they would move development to GitHub.

user1050755
  • 11,218
  • 4
  • 45
  • 56
0

It is neccesary to provide Group Id and Artifact Id to download the jar file you need. If you want to search it just use * , * for these fields.

Sati
  • 19
  • 3
  • actually this really works in the *Eclipse -> Project -> Maven -> Add Dependency* view! it seems >= 3 letter content in the `Enter groupId, artifactId...` field executes an independent search from any content in `group id` or `artifact id` ... which I would call confusing UI design. e.g. `group id: foo` + `artifact id: bar` + `enter groupId, artifactId ...: slf4j` may display multiple search results for `slf4j` libs that do not match `foo` or `bar` – Andreas Covidiot Feb 10 '22 at 19:22