Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA and Maven: Can't complete tutorial, Maven Artifact Search returns no classes

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

like image 774
user1445967 Avatar asked Jan 20 '14 20:01

user1445967


2 Answers

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

like image 146
Jakub Kubrynski Avatar answered Oct 17 '22 02:10

Jakub Kubrynski


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.

like image 34
user1445967 Avatar answered Oct 17 '22 02:10

user1445967