Found 16 Articles for Spring

Difference between Dependency Injection and Factory Pattern.

Himanshu shriv
Updated on 09-Sep-2020 08:53:23

2K+ Views

Factory and Dependency injection both are the design pattern which can be used to enhance loose coupling abilities between the software components. Factory design pattern is used to create objects. But, injection and life cycle management of the object should be handled by programmer within the application. There is no way to configure everything in a single place. Therefore, programmers need to call object creation logic wherever it needed which eventually hinder the loose coupling abilities.In DI design pattern, creation of object, injecting of the instance and life cycle management of the instance can be handled outside the code. In spring, ... Read More

Difference between IOC and Dependency Injection in Spring.

Himanshu shriv
Updated on 09-Sep-2020 08:50:55

3K+ Views

Inversion of control is a design principle which helps to invert the control of object creation.According to the paper written by Martin Fowler , inversion of control is the principle where the control flow of a program is inverted: instead of the programmer controlling the flow of a program, the external sources (framework, services, other components) take control of it. It's like we plug something into something else. He mentioned an example about EJB 2.0.Dependency Injection is a design pattern which implements IOC principle. DI provides objects that an object needs. Let’s say, class X is dependent on Y. So ... Read More

Difference Between Constructor Injection and Setter Injection in Spring

Himanshu shriv
Updated on 09-Sep-2020 08:49:37

18K+ Views

Dependency Injection is a practice to pass dependent object to other objects. Spring has two types of Dependency Injection :Constructor based Injection -When container call the constructor of the class. It should be used for mandatory dependencies.Let’s say Class X is tightly  dependent on Class Y then we should use constructor based injection.  Setter based Injection - It can be used by calling setter methods on your beans. It should be used for optional dependencies.Both types of injection has their own pros and cons. Below is a list of some differences −Sr. No.KeyConstructor based InjectionSetter based Injection1CircularIt doesn’t allow to ... Read More

Spring Boot Actuator A Production Grade Feature in Spring Boot

Samual Sam
Updated on 17-Jan-2020 11:38:12

450 Views

Spring Boot Actuator is one of the greatest and most useful feature in Spring Boot framework. Actuator module in spring boot helps application developers to implement the production grade features like metrics, health check, security, etc. with minimal effort.This article will guide you through how to enable the spring boot actuator, configure endpoints and how to modify the default settings in the application.properties file. Note that spring boot actuator can work only for the spring boot application, this can not be integrated to the non-spring boot applications.List of Endpoints SupportedHere is the list of actuator endpoints that is supported at ... Read More

Difference between Application context and Beanfactory in Spring framework

Mahesh Parahar
Updated on 18-Nov-2019 07:28:36

3K+ Views

Spring framework provides two IOC container for managing, configuring and manipulating beans. One is BeanFactory and the other is Application Context. The application context interface extends BeanFactory to enhance the functionality of BeanFactory. In new Spring versions, BeanFactory is replaced with ApplicationContext. But still, BeanFactory exists for backward compatibility. Spring version 2.0 and above, is used BeanPostProcessor extension point(Interface which provides some callback methods that we can implement to customize the instantiation logic, dependency-resolution logic and etc ). So, if you are using BeanFactory then some of the functionality such as AOP and transaction will not work without doing some extra configuration.Sr. No.KeyBeanfactoryApplication ... Read More

Difference between Save and SaveAndFlush in Spring Java

Mahesh Parahar
Updated on 18-Nov-2019 06:14:24

4K+ Views

Save and saveAndFlush both can be used for saving entities. They both are both belong to the Spring data library. save may or may not write your changes to the DB straight away. When we call saveAndFlush system are enforcing the synchronization of your model state with the DB.Sr. No.KeySaveSaveAndFlush1RepositoryIt belongs to CrudRepositoryIt belongs to JPARepository2Data flush StrategyIt doesn't flush data directly to a database until and unless we explicitly call flush and commit method.It's flush directly flush data to a database.3Bulk SaveCrudRepository provides bulk save methodsaveAndFlush method doesn't support the bulk operation 4Data Visibility after savingIt doesn't flush data directly ... Read More

Advertisements