Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a project that needs Hibernate jars.

I added them as dependencies in the pom.xml and Maven compiles my project well.

However, in the IDE, all annotations and calls to Hibernate API are marked as unresolved (red).

How could I get IntelliJ being able to resolve them ?

Is there a way to use Maven when I click on Build Project ? (ctrl+F9)

Also, I am confused with the concept of facets within IntelliJ. Do I need them, let's say JPA facets to enable Persistence assistant etc... or there's an option to let Maven take care about ?

share|improve this question
1  
Would deleting the project from IntelliJ and reimporting it help? –  user1249 Apr 15 '12 at 13:34
    
@Thorbjørn Ravn Andersen I did it, same thing doesn't work. –  Mik378 Apr 15 '12 at 13:36
    
For being more precised, I use a ServletContextListener so I needed servlet-api.jar. Maven added it well but Intellij complains about unresolved class. I could add it with the settings panel from IDE as dependency, but in doing it I would find no benefit of having Maven ..... –  Mik378 Apr 15 '12 at 13:39
2  
Those classes needed for compilation but which are provided by the web container should be mentioned with <scope>provided</scope> –  user1249 Apr 15 '12 at 15:41
1  
Finally, I entierely remove (from disk also ^^) my projects and recreated it. And Abracadabra, Maven works :) Thanks for your help !! :) –  Mik378 Apr 15 '12 at 17:16

1 Answer 1

up vote 6 down vote accepted

Clear the cache or reimport

Sometimes Intellij gets in a tangle with projects. When that happens the general approach is as follows:

  1. Try Build | Rebuild Project
  2. If no, check that the project will compile from the command line
  3. If yes, then use File | Invalidate Caches followed by Build | Rebuild All
  4. If no, then delete your local project files and check them out from version control once again using the pom.xml as the project file
  5. If no, then there is a serious problem with your Intellij installation
share|improve this answer
    
stackoverflow.com/a/11467266/32453 also lists a few even more aggressive steps. –  rogerdpack Jul 22 at 16:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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