Spring Articles

Found 15 articles

Difference between Application context and Beanfactory in Spring framework

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 4K+ Views

The Spring framework provides two IoC (Inversion of Control) containers for managing, configuring, and manipulating beans − BeanFactory and ApplicationContext. The ApplicationContext interface extends BeanFactory to provide additional enterprise-level functionality. In modern Spring versions, ApplicationContext has largely replaced BeanFactory, though BeanFactory still exists for backward compatibility. Since Spring 2.0 and above, the BeanPostProcessor extension point is used extensively. If you use BeanFactory directly, some features such as AOP proxying and transaction management will not work without extra manual configuration. BeanFactory BeanFactory is the simplest IoC container. It uses lazy loading − beans are created only when ...

Read More

nDifference between Save and SaveAndFlush in Spring Java

Teja Kolloju
Teja Kolloju
Updated on 17-Apr-2025 6K+ 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 is enforcing the synchronization of your model state with the DB. What is the save method? The save method is used to store an entity in the database. It adds the entity to the transactional buffer, and when the transaction is committed, the data is saved. It then returns the stored entity. Example The following is an example of the save method ...

Read More

Difference Between @Controller and @RestController Annotation in Spring

Shirjeel Yunus
Shirjeel Yunus
Updated on 22-Jul-2024 2K+ Views

Spring Annotations can be referred to as metadata which provides information related to a program. Supplemental information of a program can be derived from annotations. The annotation will not affect the program nor the action of the compiled program be changed. Spring annotations are of two types which are @Controller and @RestController. In this article, we will see the difference between @Controller and @RestController. What is @Control Annotation? Spring @Controller Annotation is responsible for informing that a particular class can behave in the form of a controller. The @Controller annotation and the annotated handler methods are used in combination with ...

Read More

How to Create Spring Bean in 3 Different Ways?

Harischandra Prasad
Harischandra Prasad
Updated on 16-Oct-2023 3K+ Views

Spring is a highly popular framework within the Java EE ecosystem. It is an open-source and lightweight framework that empowers Java developers to build reliable, scalable, and simplified business applications. The primary goal of this framework is to offer you a variety of tools for managing your business items. In contrast to conventional Java frameworks and APIs such as JSP, JDBC and Java Servlet, developing web applications is far simpler. In Spring, objects—primarily those controlled by the Spring IoC Container. It plays a significant role in the application. A Bean is nothing more than an object that a Spring Ioc ...

Read More

Difference Between JavaEE and Spring

Shriansh Kumar
Shriansh Kumar
Updated on 21-Jul-2023 1K+ Views

The debate about JavaEE and Spring is very common among Java developers. Both technologies emerged as popular frameworks for building enterprise applications using Java. Java EE is a more adaptable and distributed framework for developing big software. Spring, on the other hand, is open source and makes use of the POJO programming model to develop any type of Java application. Let’s find out more detailed differences between JavaEE and Spring through this article. JavaEE vs Spring JavaEE Java Platform Enterprise Edition, in short JavaEE is a set of specifications defined by Oracle. It is also known as J2EE. It aims ...

Read More

How to Implement Validation for RESTful Services with Spring

Satish Kumar
Satish Kumar
Updated on 28-Apr-2023 441 Views

As more and more applications move towards a RESTful architecture, it becomes increasingly important to ensure that the data being exchanged between the client and the server is valid. In this article, we will look at how to implement validation for RESTful services with Spring. What is Validation? Validation is the process of checking that the data being inputted or returned is valid and conforms to a set of predefined rules. These rules can be simple, such as checking that a field is not empty, or more complex, such as ensuring that a credit card number is valid. Why is ...

Read More

Difference between JDK dynamic proxy and CGLib proxy in Spring

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 3K+ Views

Spring AOP is proxy based. Spring used two types of proxy strategy one is JDK dynamic proxy and other one is CGLIB proxy.JDK dynamic proxy is available with the JDK. It can be only proxy by interface so target class needs to implement interface. In your is implementing one or more interface then spring will automatically use JDK dynamic proxies.On the other hand, CGLIB is a third party library which spring used for creating proxy. It can create proxy by subclassing. Spring uses CGLIB for proxy if class is not implementing interface.Sr. No.KeyJDK dynamic proxyCGLIB proxy1BasicIt can be only proxy ...

Read More

Difference between applicationContext.xml and spring-servlet.xml in Spring Framework

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 2K+ Views

Applicationcontext.xml - It is standard spring context file which contains all beans and the configuration  that are common among all the servlets. It is optional file in case of web app. Spring uses ContextLoaderListener to load this file in case of web application. Spring-servlet.xml- It is a single entry point for Spring. DispatcherServlet scan this file and starts to load its component. It defines the bean and configuration that are only related to that servlet.In Spring MVC application we chain them in below order −          web.xml --> dispatcher servlet --> application contextSr. No.KeyApplicationContext.xmlSpring-servlet.xml1BasicapplicationContext.xml  defines the beans that ...

Read More

Difference between DispatcherServlet and ContextLoaderListener in Spring

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 2K+ Views

ContextLoaderListener creates a root web-application-context for the web-application and puts it in the ServletContext. This context can be used to load and unload the spring-managed beans ir-respective of what technology is being used in the controller layer(Struts or Spring MVC).DispatcherServlet creates its own WebApplicationContext and the handlers/controllers/view-resolvers are managed by this context.Sr. No.KeyDispatcherServletContextLoaderListener1BasicThe task of the DispatcherServlet  is to send request to the specific Spring MVC controller ContextLoaderListener  reads the Spring configuration file (with value given against contextConfigLocation in web.xml ), parses it and loads the singleton bean defined in that config file. So we initialize the web application with ContextLoaderListener ...

Read More

Difference between @Inject and @Autowired

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 9K+ Views

@Inject and @Autowired both annotations are used for autowiring in your application.@Inject annotation is part of Java CDI which was introduced in Java 6, whereas @Autowire annotation is part of spring framework. Both annotations fulfill same purpose therefore, anything of these we can use in our application.Sr. No.Key@Inject@Autowired1BasicIt is part of Java CDIIt is part of Spring framework2RequiredIt has no required attributeIt has required attribute3Default ScopeDefault scope of the autowired beans is SingletonDefault scope of the inject beans is prototype4AmbiguityIn case of ambiguity in beans for injection then @Named qualifier should be added in your code.In case of ambiguity in ...

Read More
Showing 1–10 of 15 articles
« Prev 1 2 Next »
Advertisements