I have two classes, one is Course, another is CourseController. They are in the same package , same path; But when I compile javac CourseController.java, Intellij says :"error: cannot find symbol"
Course:
package com.mjfirstSBv5.sprintboot.learnspringboot;
public class Course {
private int id;
private String name;
private String author;
public Course(int id, String name, String author)
{
super(); //why this?
this.author = author;
this.name =name;
this.id = id;
}
@Override
public String toString() {
return "Course{" +
"id=" + id +
", name='" + name + '\'' +
", author='" + author + '\'' +
'}';
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getAuthor() {
return author;
}
}
CourseController
package com.mjfirstSBv5.sprintboot.learnspringboot;
//import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
//@RestController
public class CourseController {
public List<Course> retrieveAllCourses()
{
return Arrays.asList(
new Course(1, "learn aws", "28min"),
new Course(2, "learn spring boot", "28min" )
);
}
}
PS D:\AutoQA_Progress\intg-mock-service\learn-spring-boot\src\main\java\com\mjfirstSBv5\sprintboot\learnspringboot> javac Course.java
PS D:\AutoQA_Progress\intg-mock-service\learn-spring-boot\src\main\java\com\mjfirstSBv5\sprintboot\learnspringboot> javac CourseController.java
CourseController.java:12: error: cannot find symbol
public List<Course> retrieveAllCourses()
^
symbol: class Course
location: class CourseController
CourseController.java:15: error: cannot find symbol
new Course(1, "learn aws", "28min"),
^
symbol: class Course
location: class CourseController
CourseController.java:16: error: cannot find symbol
new Course(2, "learn spring boot", "28min" )
^
symbol: class Course
location: class CourseController
3 errors
PS D:\AutoQA_Progress\intg-mock-service\learn-spring-boot\src\main\java\com\mjfirstSBv5\sprintboot\learnspringboot>