java - Exceptions with Spring Data Rest -


i'm starting on concepts of microservices springboot , spring data rest me confusing how can few lines of code.
my main question is: have entities , repositories, spring data rest "generates" paths post requests, etc. , repository performs correctly.
but how exception handling?
example, send post without "name" field , accepted but want return error. how do that?

entity

@document public class veiculo{      @id     private string id;      @indexed(unique = true)     private string nome;     private string tipo;     @dbref     list<contato> contatos;      @dbref     list<cliente> clientes;       public string getid() {         return this.id;     }      public veiculo setid(string id) {         this.id = id;         return this;     }      public string getnome() {         return this.nome;     }      public veiculo setnome(string nome) {         this.nome = nome;         return this;     }      public string gettipo() {         return this.tipo;     }      public veiculo settipo(string tipo) {         this.tipo = tipo;         return this;     }      public list<contato> getcontatos() {         return this.contatos;     }      public veiculo setcontatos(list<contato> contatos) {         this.contatos = contatos;         return this;     }      public list<cliente> getclientes() {         return this.clientes;     }      public veiculo setclientes(list<cliente> clientes) {         this.clientes = clientes;         return this;     } } 

repository

@repositoryrestresource(collectionresourcerel = "veiculos", path = "veiculos") public interface veiculorepository extends mongorepository<veiculo, string> {     veiculo save(veiculo veiculo);      list<veiculo> findall();  } 

why don't apply javax.validation.constraints.notnull name parameter? spring data rest apply validation check , fail if value missing.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -