为什么我得到“不能被解析为类型“错误? [英] Why I got " cannot be resolved to a type" error?
问题描述
我正在 Eclipse IDE下开发一个动态Web项目(RESTful jersey)。
在 src / my / demo / service 文件夹我有 CarService.java 类
public class CarService {
...
}
在 src下/ my / demo / controller 文件夹我有 UserController.java 类
导入我的.demo.service.CarService;
public class UserController {
private CarService carService; //错误:CarServcie无法解析为类型
}
我确实导入了 CarService ,为什么eclipse会在我的 UserController.java ?中给出错误 CarServcie无法解析为类型? p>
--------编辑------------------
我发现原因:由于某种原因,在eclise项目资源管理器视图中, my.demo.service 具有与 src / 相同的级别。在我移动 my.demo.service src / 之前,没关系。看来我不应该在Eclipse的项目资源管理器视图中创建新的包...
但是谢谢你的回复:)
你只需要去项目---> clean
请参阅http://philip.yurchuk.com/2008/12/03/eclipse-cannot-be-resolved-to-a-type -error /
I am developing a dynamic web project (RESTful jersey) under Eclipse IDE.
Under src/my/demo/service folder I have CarService.java class
public class CarService {
...
}
Under src/my/demo/controller folder I have UserController.java class
import my.demo.service.CarService;
public class UserController{
private CarService carService; //ERROR: CarServcie cannot be resolved to a type
}
I do have imported the CarService, why eclipse give me the error "CarServcie cannot be resolved to a type" in my UserController.java?
--------Edit------------------
I found the cause: for some reason, my.demo.service has the same level as src/ in eclise project explorer view. After I move my.demo.service under src/, it is fine. Seems I should not create new package in "Project Explorer" view in Eclipse...
But thank you for your response:)
u just need go to Project ---> clean See http://philip.yurchuk.com/2008/12/03/eclipse-cannot-be-resolved-to-a-type-error/
这篇关于为什么我得到“不能被解析为类型“错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!