SzaboAdam SzaboAdam - 26 days ago 18
Java Question

How to generate Spring WebMVC CRUD API

What I want to do is to create a full Spring WebMVC CRUD API from database tables/Hibernate JPA entities, into an existing Maven Web Project.
What I want generate, to be precise:


  • Spring WebMVC controller (mapping&implementation)

  • The JPA entity (if not given) - ofc. using the standard generation built in to most IDEs

  • Spring Data JPA repository

  • Optionally modifying some other files (f.e. adding the entity to existing persistence.xml)



Is there a project for this?
What would be the best way to create something like this?
What I had thought about:


  • Standalone Java APP

  • Maven subgenerators

  • Eclipse plugin

  • Standard code generation methods (f.e. Acceleo plugin)



What would you suggest?

Answer

Partial Answer : If you can generate JPA entities and Spring Data JPA Repositories, you can use Spring Data REST to expose the repositories as a full CRUD REST API.