(2.)javaweb问题之xxx cannot be resolved to a type报错信息(总结)
来源:互联网 发布:手机端电影网站源码 编辑:程序博客网 时间:2024/04/26 13:46
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使用示例——基于云平台+云服务打造自己的在线翻译工具 中从IBM Bluemix上下载的Java示例代码,导入到Eclipse之后,出现类似以上错误信息!如下图:
具体解决方法请参考:HttpServlet cannot be resolved to a type
0 0
- (2.)javaweb问题之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 "eclipse报错及解决说明
- 导入到eclipse中的项目报错 XXX cannot be resolved to a type
- Button cannot be resolved to a type报错
- 关于WebServlet cannot be resolved to a type报错
- 报错:BASE64Encoder cannot be resolved to a type
- XX cannot be resolved to a type 报错
- hibernate报错:JoinColumn cannot be resolved to a type
- 报错Test cannot be resolved to a type
- java中”XX cannot be resolved to a type”的报错信息
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误分析
- JSP Xxx cannot be resolved to a type
- 关于spark的mllib学习总结(Java版)
- JDBC2和JSP初步--4月23号学习总结
- XMU 1614 刘备闯三国之三顾茅庐(二) 【逆向思维+二维并查集】
- C语言求一个序列的字典序排序
- hiho一下 第147周 小Hi的烦恼
- (2.)javaweb问题之xxx cannot be resolved to a type报错信息(总结)
- LeetCode093 Restore IP Addresses
- My sql数据库的增删改查
- 三十九、SpringBoot配置属性之Migration
- Java之函数递归
- Java DecimalFormat 用法
- 递归的理解
- 21. Merge Two Sorted Lists
- 我是如何走上"码农"的