简体   繁体   English

Maven 第一次抱怨@Override 注释,但下次编译成功

[英]Maven complains about @Override annotation first time but compiles successfully next time

I run command like this:我像这样运行命令:

mvn tomcat:redeploy 

as see a lot of errors like "...of type ImageDaoImpl must override a superclass method"看到很多错误,例如“...类型 ImageDaoImpl 必须覆盖超类方法”

But after this I do nothing, just run this command again and this time it compiles ok!但是在此之后我什么都不做,只需再次运行此命令,这次它编译正常! Could anyone tell me how to fix that?谁能告诉我如何解决这个问题? Every odd compilation time I get this error, it's quite annoying..每次奇怪的编译时间我都会收到这个错误,这很烦人..

我无法立即告诉您问题为何会消失,但通常此编译器错误表明您正在尝试使用设置为 Java 5 合规性的编译器来编译 Java 6 兼容代码(允许 @Override 实现接口)(它只允许 @Override 在覆盖超类的具体方法时使用)。

I've just resolved my issue) I have two plugins:我刚刚解决了我的问题)我有两个插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <configuration>
        <source>1.5</source>
        <complianceLevel>1.5</complianceLevel>
    </configuration>
...
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>${jdk.version}</source>
        <target>${jdk.version}</target>
    </configuration>
</plugin>

The first plugin was configured for 1.5 java the other was configured by ${jdk.version} which is 1.6 It's still a mystery for me why it compiles at all, but after setting 1.5 to 1.6 my issue has gone.第一个插件是为 1.5 java 配置的,另一个是由 ${jdk.version} 配置的,它是 1.6 对我来说它为什么编译仍然是个谜,但是在将 1.5 设置为 1.6 之后,我的问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM