@Override注解报错,The method xxx of type xxx must override a superclass method
来源:互联网 发布:电气控制柜设计软件 编辑:程序博客网 时间:2024/05/22 07:52
- 先交代环境:jdk1.8.0_65,eclipse版本: Oxygen Release (4.7.0)
今天用到@Override注解时,发现eclipse报错The method xxx of type xxx must override a superclass method,网上一查,基本都是同一篇答案,如下:
java1.5中继承接口是不需要@Override的,而在1.6中是需要添加@Override注解的,如果项目的编译器是1.5版本的就可能报错The method xxx of type must override a superclass method.
解决此问题的办法是修改java编译器的版本,方法是:elicpse的Project菜单 –> Properties –> 找到Java Compiler将Compiler Compliance level修改为1.6即可
就连stackoverflow上的回答也是这个答案:
It sounds like the JDK compliance level of your project is set to 1.5. (The version of Java installed on the machine only determines how high you can set the compliance level.) You can check this in Eclipse by opening the project properties (right click on the project name, then select “Properties”) and selecting “Java Compiler” on the left.
In Java 1.6, the @Override annotation can (and should) be used on methods that are defined in implemented interfaces. Java 1.5 did not allow this.- 解决方法:其实并不能说这个答案的方向错了,而是不够详细。。。但也许是有(我)人(太)解(菜)决(菜)了。这里应该点击右上角红色的部分:
那里可以改变具体每个项目的编译设置,点进去找到我正在写的项目,发现编译环境确实是1.5,改成跟jdk一样的版本1.8,Apply,KO! - 改完之后,@Override注解没问题了,但是可能又出现一个错误,项目上出现小红×,但是错误不在代码里,切换到下面的Markers标签,发现错误如下:
Java compiler level does not match the version of the installed Java project facet
这个错误只需打开项目的本地文件夹,找到.settings文件夹下的org.eclipse.wst.common.project.facet.core.xml文件,更改如下代码为当前使用的jdk的版本即可:
- @Override注解报错,The method xxx of type xxx must override a superclass method
- The method xxx of type xxx must override a superclass method
- [Eclipse手册]错误The method xxx of type must override a superclass method
- 报错The method *** of type *** must override a superclass method
- eclipse报错:The method convert(String) of type DateConvertor must override a superclass method;
- The method of type must override a superclass method解决方法
- The method *** of type ** must override a superclass method
- The method of type must override a superclass method 解决
- The method *** of type CourseServiceImpl must override a superclass method
- android The method of type must override a superclass method
- eclipse:the method of type must override a superclass method
- the method of type must override a superclass.
- The method xxx of type xxx must override or implement a supertype me
- The method xxx of type xxx must override or implement a supertype
- The method xxx() of type xx must override or implement a supertype method
- MyEclipse6.5 @Override 时出错误 The method of type must override a superclass method
- @Override的问题: The method of type must override a superclass method
- override方法时,eclipse提示The method *** of type CourseServiceImpl must override a superclass method
- angular+定时器
- String s = new String("xyz")创建了多少个String实例 真相大揭幕
- FFMPEG添加新的Filter
- 自定义 TextView 两端对齐
- JAVAEE 从一个Android到用javaee开发第一个接口
- @Override注解报错,The method xxx of type xxx must override a superclass method
- 84坐标系、02坐标系、百度坐标之间相互转换算法
- STM32F4实现矩阵键盘
- 如何分析java中<? extends Comparable<? super T>>
- 纪念一下,2017年9月11日粗略看完了廖大的python教程
- Java多线程--final与多线程
- 压缩流
- 汇付天下债权转让接口格式
- 数据结构与算法(6)---Java语言实现:冒泡排序