cannot be resolved to a type解决方法!!!
小楼今天在做一个Java项目的时候遇到一个大家经常遇到的问题:XXX cannot be resolved to a type

看到一百多个errors时的时候,小楼也是被吓得赶紧去找度娘。
归纳一下小楼在网上看到的这种报错的主要的几种原因:
1、jdk不匹配(或不存在)
2、jar包缺失或冲突
3、eclipse查找项目类型策略所致
相应的解决方案是:
1、jdk不匹配(或不存在)时:例如项目指定的jdk为“jdk1.6.0_18”,而当前eclipse使用的是“jdk1.6.0_22”。需要在BuildPath | Libraries,中做简单调整。
2、jar包缺失或冲突时:当找不到“XX”所在的jar包时,会报这个错。只需要找到对应jar包导入项目即可;另外,出现相同的XX时也会报此错,可能需要调包、解包、选删。
3、eclipse查找项目类型策略所致时 : eclipse下,上述两条都对比过了,没有任何问题,可偏偏还报这错。这时,需要操作一下 Project | Clean... ,问题即可解决。原因是,机制所致。因为某些特殊原因,eclipse没能自动编译源代码到build/classes(或其他classes目录),导致类型查找不到。
经分析,小楼的项目报错是由第二种原因所导致的,eclipse没能找到相应的jar包。
于是,小楼就导入了相应的jar包。
具体步骤:
(1)右键项目—>BuildPath—>Configure Build Path—>Java Build Path—>Libraries

(2)点击Add JARs...

(3)导入项目中libs下的相应的jar包

(4)导入相应的jar包后点击Apply

(5)最后错误就解决了。

cannot be resolved to a type解决方法!!!的更多相关文章
- eclipse报错:Multiple annotations found at this line: - String cannot be resolved to a type解决方法实测
Multiple annotations found at this line:- String cannot be resolved to a type- The method getContext ...
- HttpServlet cannot be resolved to a type解决方法
1:是因为没有加入servlet-api.jar 2:下载网址:http://download.csdn.net/detail/jiuyueguang/5745209 3:然后在项目右键->bu ...
- javax.servlet.jsp.JspException cannot be resolved to a type 和 javax.servlet.jsp.PageContext cannot be resolved to a type 解决办法
今天我从码云上拉一个项目下来,是个maven项目,闲来无事自己研究研究,发现刚拉下来,项目就有报错,我一看是httpServletRequest cannot be resolved to a typ ...
- js页面报错javax.servlet.jsp.PageContext cannot be resolved to a type解决
构建了一个maven项目但是项目创建好的jsp总会报错javax.servlet.jsp.PageContext cannot be resolved to a type,但是不影响项目运行.但总归难 ...
- HttpServlet cannot be resolved to a type 解决办法
刚开始学习Servlet,在Eclipse中新建了一个Servlet,不过页面上报错: Httpservlet cannot be resolved to a type,显然是Eclipse找不到相应 ...
- “selection does not contain a main type”解决方法
在运行java程序时,出现了错误“selection does not contain a main type”. 是因为.java文件不在项目的src路径内,也就是说源代码未被eclipse编译,字 ...
- [java]No qualifying bean of type 解决方法
1.错误原因:注解写错 2.原理如下: 现在的spring早就已经摆脱了之前一堆xml配置文件的情况,都是通过注解配置的方式进行依赖注入了,通常情况下,我们会有一个配置类,然后通过Annotation ...
- Servlet问题:servlet cannot be resolved to a type解决办法
工程里的路径权限高,并且eclipse并到classpath里寻找jar位置,所以我就到我的java项目里 项目名-->右键 Property-->选择 Java Build Path-- ...
- Spring MVC No converter found for return value of type 解决方法
1.在pom中添加 jackson <properties> <jackson.version>2.8.5</jackson.version> </prope ...
随机推荐
- GYCTF easy_thinking
前期储备:ThinkPHP6 任意文件操作漏洞分析 https://paper.seebug.org/1114/ 学习链接: https://www.freebuf.com/articles/web/ ...
- 深入浅出Mybatis系列五-TypeHandler简介及配置(mybatis源码篇)
注:本文转载自南轲梦 注:博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 上篇文章<深入浅出Mybatis系列(四)---配置详解之typeAliase ...
- python基础(1):第一个python程序的编写
1.第一个python编程 1.1 python的安装 1> https://www.python.org/ 进入python官网,选择目标版本进行download 2> 点击setup ...
- SpringBoot整合RabbitMQ出现org.springframework.amqp.AmqpException: No method found for class
@Component @RabbitListener(queues="my_fanout") public class Consumer { @RabbitHandler ...
- AntDesign(React)学习-10 Dva 与后台数据交互
明天正式在线办公没时间学习了,今天晚上再更新一篇, 代码提交一次:https://github.com/zhaogaojian/jgdemo 1.src下创建services目录 创建文件userSr ...
- mysql逻辑备份与还原工具mysqldump
(一)mysqldump介绍 mysqldump是MySQL自带的逻辑备份工具,类似于Oracle的expdp/impdp,mysqldump备份十分灵活,可以在以下级别对数据库进行备份: 实例下的所 ...
- Django学习笔记3
From the last two parts, we know, by using the HttpResponse we can return text to the web page, and ...
- 巨杉Tech | SequoiaDB虚机镜像正式上线
数据库云化架构需求 随着云架构的发展和流行,在业务和应用进行“云化”的过程中,云数据库因为在整体架构中的重要地位,在云化改造中的重要性不言而喻.云数据库需要满足这些技术要求,除了在功能上的具体提升,在 ...
- python中os.sep的作用以及sys._getframe().f_back.f_code.co_xxx的含义
https://blog.csdn.net/gufenchen/article/details/98338552
- bat代码中判断 bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT
· bat 代码中判断bat是否是以管理员权限运行,以及自动以管理员权限运行CMD BAT 一.判断bat是否是以管理员权限运行 @echo off net.exe session >NUL & ...