Eclipse with Maven plugin does not work with latest revisions, but works with older ones

笑着哭i 提交于 2020-01-07 02:24:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!