Skip to content

Attempt to create a 'spring-data-rest'-like CRUD controller setup in Spring Boot

Notifications You must be signed in to change notification settings

XeNz/spring-generic-controller-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generic controller POC

How to use as a consumer

  • Add your entities to the configuration below:
  • Example can be found in be.xentricator.demo.mapping.EntityMappingConfiguration
   @Bean
    public EntityMapping entityMapping() {
        Map<String, EntityMappingInformation> mappingInformation = Map.of(
                "book", new EntityMappingInformation(Long.class, Book.class)
        );
        return new EntityMapping(mappingInformation);
    }
  • A set of CRUD endpoints will now be exposed at /api/{entity}
    • For the book example above this would result in:
      • GET /api/book
      • GET /api/book/{id}
      • POST /api/book
      • PUT /api/book/{id}
      • DELETE /api/book/{id}

Possible future improvements

  • entity to DTO mapping
  • think about generic endpoint format + possibility to override endpoints (https://stackoverflow.com/a/70127945)
  • performance check
    • currently using service locator pattern vs DI
    • caching needed?

About

Attempt to create a 'spring-data-rest'-like CRUD controller setup in Spring Boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages