我有两个类,一个是Course,另一个是CourseController。它们在同一个包中,同一个路径;但是当我编译javac www.example.com时CourseController.java,Intellij说:“错误:找不到符号”
课程:
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:错误:无法找到符号public List retrieveAllCourses()^
symbol:class课程
location:class
courseController.java:15:错误:找不到符号new Course(1,“learn aws”,“28 min”),^
symbol:class课程地点:类CourseController
courseController.java:16:错误:找不到符号新课程(2,“学习 Spring Boot ”,“28分钟”)^符号:课程地点:类CourseController
3错误PS D:\AutoQA_Progress\intg-mock-service\learn-spring-boot\src\main\java\com\mjfirstSBv5\sprintboot\learnspringboot>
enter image description here
1条答案
按热度按时间fzwojiic1#
先编译课程。另一个类需要编译它。