Im using STS 2.9.1 (build on Eclipse 3.7.2) with the m2e plugin bundled with STS (v1.0.200.20111228-1245).
I have a problem with missing dependencies in an Eclipse project that contains several modules, or maybe I do not fully understand how this should work.
His project is maven.
In my project> Properties> Java Build Path> Libraries I have the "Maven Dependencies" library, but it is empty (and this is the problem).
The main POM has no dependencies, but it has several modules declared in it. Adding a dependency to POM modules does not add it to the "Maven Dependencies" library (as I expected) and causes Eclipse to show errors in the source files.
Adding a dependency to the main POM adds it to the "MD" lib, but of course I do not want to add all the dependencies of my modules to the main POM just to have it in the "MD" lib and adding every single dependency to the Build The path does not seem correct and practical.
Ive tried:
- Project> Clear,
- Maven> Update Dependencies,
- Maven> Update project configuration,
- Uncheck the box: Project> Properties> Maven> Allow Workspace Project Dependencies.
None of the above looks like a trick.
Example:
Simplified project structure:
simple.project / pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>simple.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>sample-module</module>
</modules>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
simple.project / sample module / pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>simple.project</artifactId>
<groupId>test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>test</groupId>
<artifactId>sample-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
source
share