Home » Tag Archives: Spring Boot

Tag Archives: Spring Boot

Secure Spring Boot REST API using Basic Authentication

spring-interview-questions-answers

This is the third post of my Spring Boot Blog post series. In the very first post, I talked about my experience with creating RESTFul Services using Spring Boot. Then I have expanded the sample to integrate with Swagger documentation. In this post, I am going to expand above sample with security aspect. What is API Security API Security is a ...

Read More »

Call on me, or Asynchronous REST

spring-interview-questions-answers

This article is a very simple example of a working asynchronous REST application, made with Spring Boot + Java 8. Spring Boot makes developing web applications almost ridiculously easy, but to simplify the task even more, I took an example from Spring repository called rest-service , forked it to my own repository and changed it for my purposes to create two applications: ...

Read More »

Spring Boot – spring.config.name – Case Study

spring-interview-questions-answers

Externalizing Spring Boot application properties is useful when the same application code must be used with different configuration. If the configuration is to be kept away from the source code (which is considered a best practice anyways)spring.config.location environment property can be used to point the directory location with properties files for example. On the other hand, spring.config.name can be used ...

Read More »

Building Spring Boot RESTful Service + Spring Boot Actuator

Overview What is REST? REST(REpresentational State Transfer) is the architectural style the web is built on and has become a standard software design pattern used for web applications. The term Representational State Transfer was first used by Roy Fielding, the originator of REST and one of the principal authors of HTTP specification, in his doctoral dissertation. There are many good ...

Read More »

Testing a HATEOAS service

spring-interview-questions-answers

This post is a follow up post to a few that I have written recently relating to writing a HATEOAS service and handling exceptions with Spring (Applying HATEOAS to a REST API with Spring Boot and Global exception handling with @ControllerAdvice). Now that we have looked through setting up a service and how to add some error handling via controller ...

Read More »

Using Gmail as SMTP server from Java, Spring Boot apps

spring-interview-questions-answers

Gmail users can use Gmail’s SMTP server smtp.gmail.com to send emails from their Spring Boot apps. For this let us do some setup in the app: Provide SMTP connection properties in the application.properties file: spring.mail.host=smtp.gmail.com spring.mail.username=<your gmail/google app email> spring.mail.password=***** spring.mail.port=587 spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.required=true Use Spring Boot Email tools library – which is a wrapper over Spring Boot Email starter library. ...

Read More »

Global exception handling with @ControllerAdvice

spring-interview-questions-answers

@ControllerAdvice is a annotation provided by Spring allowing you to write global code that can be applied to a wide range of controllers, varying from all controllers to a chosen package or even a specific annotation. In this brief tutorial we will focus on handling exceptions using @ControllerAdvice and @ExceptionHandler (@InitBinder and @ModalAttribute can also be used with @ControllerAdvice). I will be ...

Read More »

Integrating Swagger with Spring Boot REST API

spring-interview-questions-answers

In the last post, I talked about my experience with creating RESTFul Services using Spring Boot. When creating a REST API, proper documentation is a mandatory part of it. What is Swagger? Swagger(Swagger 2) is a specification for describing and documenting a REST API. It specifies the format of the REST web services including URL, Resources, methods, etc. Swagger will generate ...

Read More »

Applying HATEOAS to a REST API with Spring Boot

spring-interview-questions-answers

HATEOAS is an acronym for Hypermedia As The Engine Of Application State. Even after expanding that for you it still might not mean a lot. HATEOAS is an extra level upon REST and is used to present information about the REST API to the client, allowing for a better understanding of the API without the need to bring up the ...

Read More »