Spring Boot project example.
POST /api/cars Create
GET /api/cars Get all
GET /api/cars/{id} Get car by id
PUT /api/cars/{id} Update car by id
DELETE /api/cars/{id} Delete car by id
- Spring boot 1.5.8.RELEASE
- Java 8
- Oracle database 11g express
- Oracle JDBC driver ojdbc7.jar
- Lombok
- Maven
- Hibernate Core 5.0.12.Final
...
2561-03-28 11:16:07 INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1c72da34: startup date [Wed Mar 28 11:16:02 ICT 2018]; root of context hierarchy
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/api/cars/{id}],methods=[PUT]}" onto public org.springframework.http.ResponseEntity<java.lang.Void> com.bamossza.project.controller.CarController.update(int,com.bamossza.project.entities.Car)
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/api/cars/{id}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<java.lang.Void> com.bamossza.project.controller.CarController.delete(int)
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/api/cars],methods=[POST]}" onto public org.springframework.http.ResponseEntity<java.lang.Void> com.bamossza.project.controller.CarController.create(com.bamossza.project.entities.Car)
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/api/cars/{id}],methods=[GET]}" onto public org.springframework.http.ResponseEntity<com.bamossza.project.entities.Car> com.bamossza.project.controller.CarController.getById(int)
2561-03-28 11:16:08 INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/api/cars],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<java.util.Map<java.lang.String, java.lang.Object>>> com.bamossza.project.controller.CarController.getAll()
POST /api/cars
{
"carBrand": "MAZDA",
"carModel": "SKYACTIV-G 2.0",
"horsepower": "165",
"carEngine": "2000"
}
GET /api/cars
GET /api/cars/1
PUT /api/cars/1
{
"carBrand": "TOYOTA",
"carModel": "Corolla Altis",
"horsepower": "110",
"carEngine": "1600"
}
DELETE /api/cars/1
By. Panusit Khuenkham (bamossza)