Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add maven modules to IntelliJ?

IntelliJ cannot find the classes in a Maven module, even if I add the jar dependency into pom.xml.

I created a Maven module: test-intellij . And then I created a class TestApp and made it implements ApplicationContextAware as below:

public class TestApp implements  ApplicationContextAware{
}

IntelliJ told me: "can not find class ApplicationContextAware". So I pressed "alt + enter", then from the popup tips I chose "Add maven dependency".

After this operation, the dependency below was added into pom.xml successfully:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>

But when I try to import the ApplicationContextAware class , IntelliJ still cannot find the ApplicationContextAware class to import.

Could anybody help me to solve this issue?

like image 732
Ace.Yin Avatar asked Jan 22 '13 01:01

Ace.Yin


1 Answers

Try to Reimport the Maven project using the corresponding button in IntelliJ IDEA Maven Projects tool window. Wait until the dependency is downloaded and indexing is complete. File | Invalidate Caches may also help.

Also check that you are using the latest IDEA version (12.0.2 at the moment). You should be able to browse inside the downloaded dependency jar in the Project View, External Libraries node.

like image 149
CrazyCoder Avatar answered Nov 04 '22 09:11

CrazyCoder