Advanced Java Enterprise & Concurrency
24 mins read
Free Lesson
Scaffold enterprise Spring Boot microservices with @RestController, @Service, @Repository, and Spring Data JPA.
Spring Boot Production REST Controller
package com.etutorial.api;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;
import java.util.List;
@RestController
@RequestMapping("/api/v1/tutorials")
public class TutorialController {
private final TutorialService service;
public TutorialController(TutorialService service) {
this.service = service;
}
@GetMapping
public ResponseEntity<List<TutorialDto>> getAllFreeTutorials() {
return ResponseEntity.ok(service.findAllFree());
}
}