1

I have checked out a maven project into eclipse using subclipse.

I try to use the spring framework in my project, and have defined it as a required dependency:

  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>3.0.5.RELEASE</version>
  </dependency>

I have added the maven repo by adding the M2_REPO to my CLASS_PATH. I did that by executing this command on the cmd prompt:

mvn -Declipse.workspace="your Eclipse Workspace" eclipse:configure-workspace

I verified in Eclipse preferences that the M2_REPO variable is in my Classpath variable, and that the path refers to the repository directory of Maven.

However, a import statement like this:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 

does not work.

What can be the problem here?

EDIT:

Since this was a module under the root, i figured that i did not need to define the dependency on Spring once more in this module. However, including (copy paste the list from the root :s) solved the issue. But this can't be right since the POM.xml in the root already requieres that this module is included.

jorrebor
  • 2,166
  • 12
  • 48
  • 74
  • 1
    If you're using `mvn eclipse:eclipse` and `mvn eclipse:configure-workspace`, the m2eclipse tag is inappropriate. You should use maven-eclipse-plugin or m2eclipse. It doesn't make any sense to use them together. – Martin Ellis Nov 15 '12 at 16:25
  • In fact, there is no more reason to use the maven-eclipse-plugin at all, now that m2e is a top-level eclipse project – Sean Patrick Floyd Nov 15 '12 at 16:36
  • Ok sorry about that, but would also have an idea about whats going on? – jorrebor Nov 16 '12 at 08:30

1 Answers1

0

Try adding M2_REPO to your class path variables in eclipse if you are not using m2eclipse and mvn eclipse:configure-workspace didn't work..

Windows-> Preferences -> Java -> Build Path -> ClassPath Variables -> new -> M2_REPO or MAVEN_REPO and your Repo location

om39a
  • 1,406
  • 4
  • 20
  • 39