Question: how rest api works in java?
Answer: Implement the domain model. Create the Order domain class.
Implement the data source layer. Create an in-memory database. ... 
Implement the presentation layer. Create the REST endpoints. ... 
Pull the application together. Create the main method that will run the application.