Reputation: 13
I am using maven with eclipse I have struts and java ee dependencies in pom.xml
Here is my sample pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>struts</groupId>
<artifactId>struts</artifactId>
<version>1.2.9</version>
</dependency>
</dependencies>
I have not copied my whole pom.xml
Question: All my jars in dependencies are downloaded and placed in my M2_REPO. But only junit jar is used by my project. Other jars(struts and javaee) are not used by my project. When i try to import the package, it fails.
My sample java program:
package org.xinotes;
import org.apache.struts.action.ActionForm;
public class HelloForm extends ActionForm
{
private String name;
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
}
Here, it gives an error. It says "org.apache cannot be resolved".
Upvotes: 1
Views: 874
Reputation: 5160
In addition to Sebastien's answer, check your Preferences > Classpath Variables, to ensure the M2_REPO variable is pointing to the correct path.
Upvotes: 1
Reputation: 26743
Assuming you have m2e installed:
The project dependencies should then get updated, and your class should compile.
Another approach is to generate the Eclipse files from Maven:
mvn eclipse:eclipse
Upvotes: 0