Java: Spring Boot
Revision as of 13:55, 30 April 2022 by Rafahsolis (talk | contribs)
Create microservices
import java.util.Arrays;
import java.util.List;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
public class Course {
private long id;
private String name;
private String author;
public Course(long id, String name, String author){
super();
this.id = id;
this.name = name;
this.author = author;
}
public String toString() {
return "Course [id=" + id + ", name= " + name + ", author=" + author + " ]";
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getAuthor() {
return author;
}
}
@RestController
public class CourseController {
@GetMapping("/courses")
public List<Course> getAllCourses(){
return Arrays.asList(new Course(1, "Learn microservices", "in28minutes"));
}
}