Skip to Content
Hands-On Microservices with Spring Boot and Spring Cloud
book

Hands-On Microservices with Spring Boot and Spring Cloud

by Magnus Larsson
September 2019
Intermediate to advanced
668 pages
15h 59m
English
Packt Publishing
Content preview from Hands-On Microservices with Spring Boot and Spring Cloud

The util project

The util project will be packaged as a library in the same way as the api project. The source code for the util project is available at $BOOK_HOME/Chapter03/2-basic-rest-services/util. The project contains the following Java files:

  • The InvalidInputException and NotFoundException exception classes
  • The GlobalControllerExceptionHandler, HttpErrorInfo, and ServiceUtil utility classes

Except for the code in ServiceUtil.java, these classes are reusable utility classes that we can use to map Java exceptions to proper HTTP status codes, as described in the Adding error handling section. The main purpose of ServiceUtil.java is to find out the hostname, IP address, and port used by the microservice. The class exposes a method,

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Master Microservices with Spring Boot and Spring Cloud

Master Microservices with Spring Boot and Spring Cloud

In28Minutes Official

Publisher Resources

ISBN: 9781789613476Supplemental Content