I have the following snippet in my pom.xml (Full pom attached below which can be executed)
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.3</version>
</dependency>
and in one of my Java files I refer a class org.aspectj.lang.ProceedingJoinPoint
. When I do a "mvn clean install" it compiles and builds fine but when I do an eclipse:eclipse, and import the project in eclipse it gives me an error The import org.aspectj cannot be resolved
. I checked the .classpath file that was generated and it does not have an entry to this file. I tried a "mvn dependency:tree" and it lists this fine.
I don't have any fancy settings for not compiling any java files. It is just a routine pom which puzzles me.
Can someone tell me what is going wrong here?
UPDATE 1: I am using maven eclipse plugin Version: 2.7
UPDATE 2: Just use pom below and do a mvn eclipse:clean eclipse:eclipse
from the command line
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ekanathk</groupId>
<artifactId>stackoverflow</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
</project>
I had similar problem. Running mvn eclipse:clean
and then mvn eclipse:eclipse
helped.
I've had similar problem. Eclipse plugin for maven assumes Eclipse has its own support for AspectJ. So you need to tell it you have none (or tell it which version you have). Adding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<ajdtVersion>none</ajdtVersion>
</configuration>
</plugin>
to <build>
<plugins>
section should help.
I just tried to reproduce the problem and... couldn't. This is the .classpath
I get after adding the aspectj:aspectjrt:jar:1.5.3 dependency to a freshly created project:
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/aspectj/aspectjrt/1.5.3/aspectjrt-1.5.3.jar">
<attributes>
<attribute value="jar:file:/home/pascal/.m2/repository/aspectj/aspectjrt/1.5.3/aspectjrt-1.5.3-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
What version of the maven eclipse plugin are you using? Did you configure it to use AJDT? Can you show your configuration?
Have you tried using m2eclipse instead? It tends to produce much better results in my experience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With