aedsferrao
aedsferrao

Reputation: 33

Unable to solve import classes in maven project

I am developing a maven project using IntelliJ-14. The other day everything was correct without any problem but today when I got in the project some of my imports are not working. When I compile it is everything ok and I can run the project but autocomplete does not work and some classes appear red.

I've tried to go File-> Settings-> Maven-> Importin-> Import Maven Projects Automatically check. Already imported the project again and nothing. In external libraries classes exist.

An example of my code is here.

What else can I do to solve this?

Please help

Upvotes: 1

Views: 6167

Answers (3)

zpontikas
zpontikas

Reputation: 5662

Some possible solutions since we can't tell what is actually wrong:

  1. Delete your .m2 folder and do a reload maven project
  2. Go invalidate "caches and restart" (File - Invalidate caches / Restart)
  3. If you work with other people see if they have committed something that breaks the maven build. Some times the version of jars that you have in your local maven repo (.m2 folder in your %USER_HOME% folder) is different than the one that they other devs using
  4. Do "Reimport all maven projects"
    Reimport all maven projects

Upvotes: 1

JimHawkins
JimHawkins

Reputation: 5000

I experienced the same problem. Before it occured, I created a package structure from within IDEA, for example "de.ulli.myPackage". Of course I expected to get the directory structure "de/ulli/myPackage". I don't know why, but actually there was a single directory named "de.ulli.myPackage" (OS Windows 7 64 Bit). Maven was able to build the project, and I even could generate classes via IDEA. But autocomplete didn't work and the classes within the package appeared red in other sources. After reparing the directory structure, everything was fine.

Upvotes: 0

user3420419
user3420419

Reputation: 21

Right click on the project-->Maven--->UpadateProject. This may help you.

Upvotes: 2

Related Questions