Posted in Spring Boot Spring REST Spring Security

Spring Security Pre-Authentication with Spring Data JPA

Introduction In this example I am going to show you Spring Security Pre-authentication hasrole with Spring Data JPA. In my another example I had shown the similar example on Spring Security Pre-Authentication with Spring JDBC Template. There are situations where you want to use Spring Security for authorization, but the user has already been reliably authenticated by some external system…

Continue Reading... Spring Security Pre-Authentication with Spring Data JPA
Posted in Spring Boot Spring Core

Inject Prototype Bean into Singleton Bean in Spring – Lookup Method Injection

Lookup Method In this tutorial I am going to show you how lookup method injection works in Spring framework. You may face a situation where you need to inject prototype scoped bean into singleton scoped bean. For singleton scoped bean a new instance or object is created and the same is returned each time it is injected or looked up….

Continue Reading... Inject Prototype Bean into Singleton Bean in Spring – Lookup Method Injection
Posted in Spring

Top 10 best practices while building applications using Spring framework

Introduction In this tutorial I am going to discuss about best practices while building applications using Spring framework. Recently Spring has been one of the most popular Java based framework for building enterprise applications. Anyone can grasp the basic concepts and starts building applications using Spring right away but to become a strong developer you need to put efforts and…

Continue Reading... Top 10 best practices while building applications using Spring framework
Posted in Spring Core

Spring bean life cycle call back Methods Example

Spring framework provides bean life cycle call back methods to perform some additional tasks which you may want to perform when a bean is initiated or created or when a bean is about to get destroyed. Therefore you can run a method which will do some initialization process during bean initialization and you can run another method which will do…

Continue Reading... Spring bean life cycle call back Methods Example
Posted in Spring Core

InitializingBean and DisposableBean in Spring

Spring InitializingBean and DisposableBean are the interfaces used in life cycle of Spring beans management. Each of these interfaces has only one method. InitializingBean has a method called afterPropertiesSet() and DisposableBean has a method called destroy(). Spring container runs the method afterPropertiesSet() once the bean properties have been set and Spring container runs destroy() method once Spring container releases the…

Continue Reading... InitializingBean and DisposableBean in Spring
Posted in Spring Core

Custom init() and destroy() methods in Spring

Introduction In this tutorial we will discuss on Spring custom init() and destroy() methods. These methods are call back methods which used in Spring life cycle. You can use these methods to to some initialization and clean up jobs just after the bean is created by the Spring container or just before the bean is about to be destroyed by…

Continue Reading... Custom init() and destroy() methods in Spring
Posted in Spring Core

BeanPostProcessor in Spring

BeanPostProcessor in Spring is used for extending the functionality of framework if want to do any configuration Pre- and Post- bean initialization done by spring container. By default, Spring will not aware of the @PostConstruct and @PreDestroy annotation. To enable it, you have to either register CommonAnnotationBeanPostProcessor or specify <context:annotation-config/> in the bean configuration file. Here CommonAnnotationBeanPostProcessor is predefined BeanPostProcessor…

Continue Reading... BeanPostProcessor in Spring
Posted in Hibernate MySQL Spring Boot

Spring Boot MVC and Hibernate CRUD Example

Introduction In this tutorial we will create an example on Spring Boot MVC and Hibernate CRUD. CRUD is an acronym that means Create, Read, Update and Delete operations. In my other tutorial I had also created Spring Boot MVC and JDBC CRUD Example. We will build the tutorial example using both maven and gradle build tools. We will create the…

Continue Reading... Spring Boot MVC and Hibernate CRUD Example
Posted in Spring Boot Spring JDBC Spring MVC Spring Transaction

Spring Boot MVC and JDBC CRUD Example

Introduction In my other tutorial I had shown how to create an example on Spring MVC and JDBC CRUD example using annotations only, but here I am going to use Spring Boot framework. I did not update the other tutorial keeping in mind if someone still needs the example using Spring framework only. Here also I am going to show…

Continue Reading... Spring Boot MVC and JDBC CRUD Example
Posted in MySQL Spring Boot Spring JPA

Spring Data JPA Entity Graphs

One of the important features in Spring Data JPA or simply JPA is the ability to specify fetch plans using Entity Graphs. This is useful since it allows you to customize the data, which is retrieved with a query or find operation. It is expected to display data from the same entity in different and several ways when working with…

Continue Reading... Spring Data JPA Entity Graphs