java:xxx cannot be resolved to a type
来源:互联网 发布:android网络框架 编辑:程序博客网 时间:2024/05/28 18:43
xxx cannot be resolved to a type
引言
eclipse新导入的项目经常可以看到“XX cannot be resolved to a type”的报错信息。本文将做以简单总结。正文
(1)jdk不匹配(或不存在)
项目指定的jdk为“jdk1.6.0_18”,而当前eclipse使用的是“jdk1.6.0_22”。需要在BuildPath | Libraries,中做简单调整。
(2)jar包缺失或冲突
当找不到“XX”所在的jar包时,会报这个错。解决只需要找到(ctrl+点击,可能能看到jar包名称)对应jar包导入项目即可。
另外,出现相同的XX时也会报此错。可能需要调包、解包、选删。
(3)eclipse查找项目类型策略所致
eclipse下,上述两条都对比过了,没有任何问题,可偏偏还报这错。这时,需要操作一下 Project | Clean... ,问题即可解决。原因是,机制所致。因为某些特殊原因,eclipse没能自动编译源代码到build/classes(或其他classes目录),导致类型查找不到。
编码问题
以上这些是比较常见的错误,我这里遇到的错误是文件编码导致的!
错误类似下图,这里只截取一部分:
解决方法:
在发生错误的项目上单击鼠标右键》Properties
左侧选中“Resource”,右侧Text file encoding选择“Other:UTF-8”,点击“Apply”按钮。
2015-12-13更新
很多小伙伴反馈,经过上面的步骤还是不能解决问题,刚好最近遇到这样的问题;在文章 Java中REST API使用示例——基于云平台+云服务打造自己的在线翻译工具 中从IBMBluemix上下载的Java示例代码,导入到Eclipse之后,出现类似以上错误信息!如下图:
具体解决方法请参考:HttpServlet cannot be resolved to a type
转载自:http://blog.csdn.net/testcs_dn/article/details/39643119
- 微wx笑
0 0
- xxx cannot be resolved to a type
- xxx cannot be resolved to a type
- XXX cannot be resolved to a type!
- xxx cannot be resolved to a type
- XXX cannot be resolved to a type
- java:xxx cannot be resolved to a type
- Java错误提示------xxx cannot be resolved to be a type
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误分析
- JSP Xxx cannot be resolved to a type
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- HashMap工作原理
- linux启动流程
- 通过程序访问页面-HTTP请求
- meta中的viewport指令
- 一周总结
- java:xxx cannot be resolved to a type
- 总结iOS App开发中控制屏幕旋转的几种方式
- 第一次写博客
- PHP 加载一次页面时, 浏览器请求多次, 导致出错
- Shell中while循环的done 后接一个重定向<
- 一个小脚本----各种编译命令合入到同一个脚本
- wampserver安装完之后图标一直显示红色解决方法
- 输出数字2016-10-31 15:39:58.188是Timestamp类型 ,sql拼装
- unity3D游戏开发十七之NGUI四