An open API service indexing awesome lists of open source software.

https://github.com/rosyid-grobogan/spring-workout-1

Master Java Web Services and REST API with Spring Boot
https://github.com/rosyid-grobogan/spring-workout-1

restful-webservices spring spring-boot

Last synced: 2 months ago
JSON representation

Master Java Web Services and REST API with Spring Boot

Awesome Lists containing this project

README

          

# Workout for Master Java Web Services and REST API with Spring Boot

## RESTful Web Services

## Social Media Application Resource Mapprings
## User -> Posts

* Retrieve all Users - GET /users
* Create a User - POST /users
* Retrieve one Users - GET /users/{id} -> /users/5
* Delete a User - DELETE /users/{id} -> /users/5

## Exercise User Post Resource and Exception Handling
* Retrieve all posts for a User - GET /users/{id}/posts
* Create a posts for a User - POST /users/{id}/posts
* Retrieve details of a post - GET /users/{id}/posts/{post_id}

## Error in the Log
```
Resolved exception caused by Handler execution:
```

## Internationalization
### Configuration
- LocaleResolver
- Default Locale - Locale.US
- ResourceBundleMessageSource

### Usage
- Autowire MessageSource
- @RequestHeader(value = "Accept-Language, required = false) Locale locale
- messageSource.getMessage("helloWorld.message", null, locale)

## Application.properties
```
logging.level.org.springframework = info
#This is not really needed as this is the default after 2.0.0.RELEASE
spring.jackson.serialization.write-dates-as-timestamps=false
spring.messages.basename=messages
management.endpoints.web.exposure.include=*
spring.security.user.name=username
spring.security.user.password=password
spring.jpa.show-sql=true
spring.h2.console.enabled=true
```

## Addtion for Dependencies in pom.xml
```

org.springframework.boot
spring-boot-starter-hateoas

com.fasterxml.jackson.dataformat
jackson-dataformat-xml

org.springframework.boot
spring-boot-starter-actuator

org.springframework.data
spring-data-rest-hal-browser

io.springfox
springfox-swagger2
2.4.0

io.springfox
springfox-swagger-ui
2.4.0

org.springframework.boot
spring-boot-devtools
runtime

com.h2database
h2
runtime

```

## Swagger
### Document API
```
localhost:8080/v2/api-docs
```
### Swagger UI
```
localhost:8080/swagger-ui.html
```