반응형
SMALL
package com.in28minutes.springboot.learnspringboot;
import java.lang.ModuleLayer.Controller;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CourseController {
@RequestMapping("/courses") //"주소"
public List<Course> retrieveAllCourses(){
return Arrays.asList(
new Course(1, "Learn AWS", "in28minutes"),
new Course(2, "Learn DevOps", "in28minutes")
);
}
}
package com.in28minutes.springboot.learnspringboot;
public class Course {
private long id;
private String name;
private String author;
//Constructor
public Course(long id, String name, String author) {
super();
this.id = id;
this.name = name;
this.author = author;
}
//toString
@Override
public String toString() {
return "Course [id=" + id + ", name=" + name + ", author=" + author + "]";
}
//Getters
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getAuthor() {
return author;
}
}
반응형
LIST
'Spring > Spring Boot' 카테고리의 다른 글
H2콘솔 및 테이블 생성 (0) | 2023.08.27 |
---|---|
spring-boot actuator 사용 (0) | 2023.08.27 |
@ConfigurationProperties(prefix = "~") (0) | 2023.08.27 |
로깅 방법, 종류 (0) | 2023.08.27 |
Spring Boot Davtools로 빠르게 빌드 (0) | 2023.08.27 |