Maven项目:@Override is not allowed when implement interface method

之前在Eclipse下开发Java程序,@Override使用正常。

现在切换到Intellij IDEA开发,同样的代码,@Override却显红编译不通过。

 

实际上,这是Maven项目遇到的问题。Intellij IDEA和Eclipse下都会遇到这个问题。

 

解决方法:

由于我的项目是maven类型项目,所以在pox.xml的<build></build>标签中添加如下代码,即可解决问题。

 

  <build>
    <finalName>spirngMVC</finalName>
    <plugins>
      <!-- 编码和编译和JDK版本 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>utf8</encoding>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

 

版权声明:本文为博主原创文章,欢迎转载。 https://blog.csdn.net/chengyuqiang/article/details/54600499
posted @ 2018-08-02 20:41  Graffiti  阅读(325)  评论(0编辑  收藏  举报