Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

java - Why I got " 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...