Код: Выделить всё
@RestController
public class Controller {
@Autowired
private Repository repository;
private Service service = new Service(this.repository);
@PostMapping(value = "/")
public void add(@RequestBody Entity entity) {
bookService.addBook(book);
}
}
Код: Выделить всё
@Service
@AllArgsConstructor
public class Service {
@NotNull
private Repository repository;
public void add(Entity entity) {
repository.save(entity);
}
}
Код: Выделить всё
@Repository
public interface Repository extends JpaRepository {}
Можете ли вы помочь мне понять, чего мне не хватает?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -a-service
Мобильная версия