Skip to content

tratif/specification-arg-resolver-example-springboot3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Some examples for SpecificationArgumentResolver with Spring Boot 3

This is a simple Spring Boot project which presents Specification Argument Resolver library.

It is an executable jar with embedded H2 db, so just build it with Maven and explore the API. It is also configured to be compiled as native image.

Build

How to build the app:

  • jar
    • executable - mvn clean install
    • docker image mvn spring-boot:build-image
  • native
    • executable - mvn -Pnative native:compile (should be visible as executable file in target directory)
    • docker image - mvn -Pnative spring-boot:build-image It is recommended to run tests against native image to be sure, that the native image contains all the code that is required at runtime:
  • mvn -PnativeTest test

(Native image tested with maven 3.8.7 and GraalVM 22.3.0 for java 17 SDK version)

Usage examples

You will find some samples below:

  1. Get all customers:

    curl http:https://localhost:8080/customers

  2. Delete a customer

    curl -X DELETE http:https://localhost:8080/customers/3

    it will perform a soft delete, which you can verify by getting all customers again -- the deleted customer will be still there, but with deleted = true flag. As you will see in subsequent points, specification-based query methods will filter it out.

  3. Filter customers (include only not deleted ones) by first name:

    curl http:https://localhost:8080/customers?firstName=ar

  4. Filter customers by last name and gender (gender param is optional):

    curl http:https://localhost:8080/customers?lastName=simp curl 'http:https://localhost:8080/customers?lastName=simp&gender=M'

  5. Filter customers by name (either first or last, case insensitive) with paging:

    curl 'http:https://localhost:8080/customers?name=l&page=0&size=2&sort=id'

  6. Filter customers by registration date:

    curl http:https://localhost:8080/customers?registeredBefore=2014-01-22 - returns customers registered before given date curl 'http:https://localhost:8080/customers?registeredAfter=2014-01-01&registeredBefore=2014-01-22' - returns customers registered between given registeredAfter and registeredBefore params

  7. Filter customers by name (either first or last, case insensitive) and gender:

    curl 'http:https://localhost:8080/customers?name=l&gender=F'

  8. Filter customers by registration date (customers registered before given date) and name (either first or last, case insensitive). It will return only not deleted customers:

    curl 'http:https://localhost:8080/customers?registeredBefore=2014-01-22&name=simp'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages