问题
I have a simple project that uses Spring AOP. It uses annotation from AspectJ. The project is in Maven and it compiles ok with aspectjtools-1.7.4
. With aspectjtools-1.8.9
it fails to see accept annotation @Aspect
imported from org.aspectj.lang.annotation.Aspect
. The same project gives no problems with Gradle and same JARs.
Why would my code not work with latest revision of AspectJ, but works ok with older one?
I am attaching pom.xml:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>aspectjproblem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>aspectjproblem</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<!-- WITH 1.8.9: FAILS to see org.aspectj.lang.annotation.Aspect -->
<!-- <version>1.8.9</version> -->
<!-- WITH 1.7.4: SEES OK: org.aspectj.lang.annotation.Aspect -->
<version>1.7.4</version>
</dependency>
</dependencies>
</project>
I guess it must have something to do with compliance-levels or similar things. Can anyone point me in the right direction? Many thanks.
回答1:
It took me a while to understand what was the issue. I tried moving to Java8 and I played with dependencies. The problem I had was:
- Invalid LOC header (bad signature)
What means I guess Maven downloaded a corrupted file. I deleted it from repo (e.g. C:\Users\$USER.m2\repository\org\aspectj\aspectjtools ), updated maven and all started working again.
来源:https://stackoverflow.com/questions/39893218/eclipse-with-maven-plugin-does-not-work-with-latest-revisions-but-works-with-ol