Retrieve User Information in Spring Security 1. Overview This article will show how to retrieve the user details in Spring Security. The currently authenticated user is available through a number of different mechanisms in Spring – let’s cover the most common solution – programmatic access, first. Further reading: Keep Track… Continue Reading get-user-in-spring-security

Negate a Predicate Method Reference with Java 11 1. Overview In this short tutorial, we’ll see how to negate a Predicate method reference using Java 11. We’ll start with the limitations encountered in order to achieve this before Java 11. Then we’ll see how the Predicate.not() method helps, as well. 2. Before… Continue Reading java-negate-predicate-method-reference

Dynamic Mapping with Hibernate 1. Introduction In this article, we’ll explore some dynamic mapping capabilities of Hibernate with the @Formula, @Where, @Filter and @Any annotations. Note that although Hibernate implements the JPA specification, annotations described here are available only in Hibernate and are not directly portable to other JPA implementations.… Continue Reading hibernate-dynamic-mapping

Spring RestTemplate Error Handling 1. Overview In this short tutorial, we’ll discuss how to implement and inject the ResponseErrorHandler interface in a RestTemplate instance – to gracefully handle HTTP errors returned by remote APIs.  2. Default Error Handling By default, the RestTemplate will throw one of these exceptions in case of… Continue Reading spring-rest-template-error-handling

The @ServletComponentScan Annotation in Spring Boot 1. Overview In this article, we’ll go through the new @ServletComponentScan annotation in Spring Boot. The aim is to support the following Servlet 3.0 annotations: javax.servlet.annotation.WebFilter javax.servlet.annotation.WebListener javax.servlet.annotation.WebServlet @WebServlet, @WebFilter, and @WebListener annotated classes can be automatically registered with an embedded Servlet container by… Continue Reading spring-servletcomponentscan