错误调试解析:class cannot be resolved to a type 或者JSP import class cannot be resolved to a type
import XXX.XXX cannot be resolved to a type , import XXX.XXX cannot be resolved错误处理解析
类的引用不可定义为一种。
出现这种问题的情况一般是你的引用出现了二义性。
比如你引用了classes.pack.num1,但是你同时在根文件夹下有一个classes的文件夹,和把此classes文件打包成的jar包,又或者你的classpath环境变量配置的过程中同时出现了路径"."和“XXX.jar”而有两个同名同路径的.class文件可以被找到,就会引发此问题。
很多时候用vi编辑.java文件的时候,默认使用的编译存放路径是".",就是说同目录下。
eclipse工程中默认.java文件的位置是src,编译文件.class的位置是classes,这种情况下, 使用手动测试的时候会出现在src的文件夹下也会生成出.class文件,如果系统环境变量中有classpath="."的定义时,再次使用eclipse编译时,就会出现class cannot be resolved to a type,因为同时可以找到两个同名同路径的.class文件。
JSP impot class cannot be resolved to a type我的问题出在eclipse编译时把.class文件放在了classes文件夹下,但是tomcat去找的时候,只找了"."文件夹,结果就找不到。而在编写的时候,eclipse是能找到的,所以编写时不报错,运行时报错。如果你在.文件夹下也生成.class文件,tomcat能找到了,eclipse又找重了,还是不行。
我的解决办法是,在tomcat启动时,为tomcat添加引用路径,先把classes文件夹导入到JVM中。tomcat在调用类的时候,就不会找不到了。
具体操作方法是,使用eclipse的tomcat插件,在eclipse的主界面菜单window下的preferences对话框中找到tomcat插件的那一项,选择JVMsetting,有一个classpath(before generated classpath)中,导入你的classes文件夹。就可解决此问题。
相同的,如果tomcat运行时出现了找不到引用的jar包,也可以在这里设置导入。
结合我自己的jsp出现的问题,因为包结构里的一个包名和同目录里的一个类名名称相同,出现这个异常
分享到:
相关推荐
主要介绍了详解 问题:HttpServlet cannot be resolved to a type的相关资料,需要的朋友可以参考下
> ★BasicNameValuePair cannot be resolved to a type > ★HttpPost cannot be resolved to a type > ★NameValuePair cannot be resolved to a type > ★HttpClient cannot be resolved to a type > ★Http cannot...
主要介绍了java eclipse 出现 xxx cannot be resolved to a type 错误解决方法的相关资料,需要的朋友可以参考下
导入工程的“The import android cannot be resolved”错误解决方法
cocos The import com.loopj cannot be resolved 是缺失了jar包。导入lib文件夹,或者刷新eclipse就好了。
测试类报错Test cannot be resolved to a type-附件资源
JSONObject cannot be resolved to a type 是因为缺少对应的依赖包:org-json.rar 包的来源github的项目:https://github.com/stleary/JSON-java中的Readme可以找到依赖包的地址。
jce.jar/jsse.jar解决The import javax.crypto cannot be resolved的问题
org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved 解决 替换JAR包即可
解决The type org.springframework.dao.support.DaoSupport cannot be resolved.bao报错
rsslib4j-0.2.jar jar包,解决java报错找不到资源包问题 The import org.gnu cannot be resolved。 报错 import org.gnu.stealthp.rsslib.*; RSSChannel、RSSException、RSSHandler、RSSItem、RSSParser
ITextRenderer cannot be resolved to a type 错误就是因为缺少这个jar包
JSTL 标签 发生 uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application问题时解决方法
NULL 博文链接:https://zuoqiang.iteye.com/blog/1337682
用JAVA编写的一个Stratego游戏,类似于国内的军棋游戏,能够实现网络对战。附上源代码,编写类似游戏的同学可以借鉴借鉴。...PS:用eclipse运行出现错误:HelpFrame cannot be resolved to a type. 望高手解答。
Word模板-授权委托书.wpt
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
JSONObject所必须要用到的6个包,他们分别是commons-beanutils-1.7.0.jar、commons-collections-3.1.jar、commons-lang-2.5.jar、commons-logging.jar、ezmorph-1.0.3.jar、json-lib-2.1-jdk15.jar
The type org.apache.tools.ant.Task cannot be resolved. It is indirectly referenced from required .class files错误....., 解决办法:在工程中加入此jar包