Autogenerate spring-rest architecture for CRUD operations?

I want to create a backend application that supports database entries and offer them via REST

. So I want to use spring

.

Is there any tool out there that could auto-generate CRUD and service classes for this purpose? Because these operations are always the same or at least similar for every object.

Example:

@Entity
class MyEntity {
   //some properties to be explosed to REST, some not
}


@Controller
public class ServiceController {
    //fetch DB entries and offer them to the rest facade
}


@Service
public class RestService {
    //expose GET functions via REST/JSON/XML
    //@RequestMapping(..GET..)
}

      

Or are there other possibilities to simplify initial development?

+3


source to share


1 answer


As pointed out in the comments, Spring Data Rest does exactly that.

You will get CRUD operations, Hypermedia filtering capabilities, sorting, pagination ... all accessible via REST.

Spring Data Rest relies on Spring Data, so whichever persistence technology you use will work as long as Spring Data supports it. Also, it uses Spring HATEOAS for all Hypermedia stuff.



To get started, just look at the official documentation.

As a personal opinion, this is a great project to speed up RESTful apis, you tend to need a shadow method to get finer control over some specific situations, but still definitely worth it.

+1


source







All Articles