eclipse新导入的项目经常可以看到“XX cannot be resolved to a type”的报错信息
2017-05-08 15:01
537 查看
引言
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使用示例——基于云平台+云服务打造自己的在线翻译工具 中从IBM
Bluemix上下载的Java示例代码,导入到Eclipse之后,出现类似以上错误信息!如下图:
具体解决方法请参考:HttpServlet
cannot be resolved to a type
相关文章推荐
- 导入到eclipse中的项目报错 XXX cannot be resolved to a type
- 导入到eclipse中的项目报错 XXX cannot be resolved to a type
- java中”XX cannot be resolved to a type”的报错信息
- Eclipse导入其他Eclipse写的Android项目error:Activity cannot be resolved to a type
- java 项目导入Eclipse时出现错误:httpservletrequest cannot be resolved to a type
- "XX cannot be resolved to a type "eclipse报错及解决说明
- "XX cannot be resolved to a type "eclipse报错及解决说明
- 【公司项目总结】(三)---解决XX Cannotbe resolved to a type 报错思路
- Eclipse luna 导入web项目出现错误 String cannot be resolved to a type
- "XX cannot be resolved to a type "eclipse报错及解决说明
- Android Eclipse导入源码时对自己新增的class文件提示"XXX cannot be resolved to a type"的解决办法
- "XX cannot be resolved to a type "eclipse报错及解决方法参考
- "XX cannot be resolved to a type "eclipse报错及解决说明
- eclipse下项目报错class path resource [com/xzhang/mapping/] cannot be resolved to URL because it does not
- Eclipse 导入web项目后 报 The type javax.servlet.http.HttpServletRequest cannot be resolved.
- "XX cannot be resolved to a type "eclipse报错及解决
- "XX cannot be resolved to a type "eclipse报错及解决
- eclipse,myeclipse导入工程报:javax.servlet.jsp.JspException cannot be resolved to a type
- maven项目工程报错:cannot be resolved to a type
- 关于AndroidStudio项目转换Eclipse项目报错“AppCompatActivity cannot be resolved to a type”