8

I'm working through the tutorial here for using Maven under IntelliJ: http://wiki.jetbrains.net/intellij/Creating_and_importing_Maven_projects

I'm up to the 'working with dependencies' section. I try to add a Maven Dependency using Maven Artifact Search. In the 'search for class' tab, nothing shows up, no matter what I type in the search box. Under 'search for artifact', about two dozen dependencies show up at the start.

Most of the discussions about this type of issue suggest a problem with Maven settings in IntelliJ. I confirmed that the Maven home directory is set properly. Under 'Repositories', the http://repo1.maven.org/maven2 URL is there and I was able to update it.

I used search.maven.org to double check that searching by class name does produce a result for the value I search for, "TestCase". I am using Maven 3.1.1, Windows 7 x64, JDK 1.7 64bit.

Update: Maven works, i.e. goals can be run and they will download dependencies and build the project, if I edit pom.xml manually. However the Artifact Search cannot find any class, ever. I included a screenshot of what shows up when I use Artifact Search to search for artifacts. (Link to my image does not seem to appear even though I uploaded right to SO, not sure why... maybe imgur is blocked at my location)

Only Artifact Search finds anything, and only these items

user1445967
  • 1,520
  • 4
  • 14
  • 30

2 Answers2

16

Please navigate in Settings to Project settings -> Maven -> Repositories Then find repo1 on your list and click "Update" - that will rebuild your repositories indexes and search for class will work

Jakub Kubrynski
  • 13,724
  • 6
  • 60
  • 85
  • 1
    That sounds like a good suggestion based on what I've seen in similar posts. Unfortunately I already did this as I tried to describe in my 3rd paragraph, sorry if I was not clear on that. – user1445967 Jan 20 '14 at 21:31
  • Have you found anything interesting in Idea log file? – Jakub Kubrynski Jan 20 '14 at 21:33
  • 1
    Unfortunately nothing at all that represents a problem or is related to Maven – user1445967 Jan 20 '14 at 21:43
  • There are just few artifacts on your dialog - what class are you trying to find? Could you try something like "ServletContext"? – Jakub Kubrynski Jan 20 '14 at 21:48
  • Can't find that class, unfortunately. I haven't figured out how to remedy this, although I have updated from repo1 a number of times. It is definitely helpful to know the name of a class that maven -should- be able to find – user1445967 Jan 20 '14 at 21:55
  • Yes (Idea has sometimes problems with indexing repository - you just have to retry) and yes (it helps when you know class name) :) – Jakub Kubrynski Jan 20 '14 at 21:59
4

FIXED:

I got an idea from reading this question discussing what a snapshot is and why it is not usually updated.

Force Intellij IDEA to reread all maven dependencies

I went into IntelliJ Settings -> Maven and enabled "Always Update Snapshots" and I also changed "Plugin Update Policy" to "Check For Updates". (Even though I don't know exactly what that second one means, and IntelliJ says it's not important for my version of Maven anyway)

Immediately I was able to locate the ServletContext class in the Artifact Search. This is before I even updated from repo1 on the Repositories screen.

I can't really say why this did the trick but it seems to have worked. Thanks to @JakubK for helping me explore toward the solution!

Certainly this is the sort of issue that leads one to consider giving up (and starting to reinstall things...!), hopefully this helps someone else at some point.

Community
  • 1
  • 1
user1445967
  • 1,520
  • 4
  • 14
  • 30