Top 100 Spring Interview Questions and Answers

Spring AOP framework has gained a lot of popularity in the past few years. It is a framework that supports java. These days learning the programming language is not enough. You need to know how to answer the spring interview questions.

Cracking a spring interview may not be the easiest. However, we have a wide list of spring interview questions that will make your spring interview easy to tackle. You can skim through these 100 interview questions right before your interview. 

Contents show

Spring Interview Questions and Answers

Q1. What is Spring Framework?

Spring Framework is a supporting environment used for java programming. It is an open source platform that helps in J2EE coding simpler. It keeps a check on all best practices for programming. It is also known as the ‘king of frameworks’ as it also works with other platforms such as Hibernate, EJB, Struts, etc. 

Q2. What is a Spring Bean?

Objects that are managed by the spring IoC containers are referred to as beans in the spring framework. It is part of the spring bean factory. Following are the functions that are performed with bean scopes:-

  • Instantiation 
  • Assembly 
  • Management of Spring  container

The beans are used to configure the metadata in the spring container. Below is a list of bean scopes in the spring framework.

  1. Class
  2. Name
  3. Scope
  4. Constructor-arg
  5. Properties
  6. Autowiring mode
  7. Initialization method
  8. Destruction method
  9. Lazy-initialization mode

Q3. Explain Spring Bean Lifecycle 

Spring Interview questions - Spring Bean Lifecycle

In order to be able to use the bean, it has to be instantiated. In case there is no work left for the bean in the spring container, it can be removed. This will need to be done through some clean-up. There are a set of events that occur between the instantiation and destruction of the bean. The primary focus is on the callback methods. Here is a simple way to demonstrate a bean life cycle. 


void methodcallback() throws Exception; 
public class sampleBean implements StartBean { //configuration metadata
public void methodcallback() {


void timetodestroy() throws Exception;
public class sampleBean implements LeaveBean {
public void timetodestroy() {
Spring Bean Life Cycle
Spring Bean Life Cycle

Q4. What do you mean by Dependency Injection? 

It is a basic concept in the spring framework. Container places objects inside other dependencies. This shifts the responsibilities to the containers. It basically lifts off some of the burden placed on the written code in the bean configuration file. 

Expressing it in a code:-

class Salary{  
Work work;  // work is a class here
Employee(Work work){;  
public void setWork(Work work){;  // configuration metadata

Q5. What are the different bean scopes in spring?

singletonSingle instance per Spring IoC container
prototypeOne spring bean mapped to many instances
requestFor HTTP requests
sessionFor HTTP session
Global sessionGlobal Http session

Q6. What are the major features in different versions of Spring Framework?

Spring 2.5Spring 3.0Spring 4.0
Configuration is annotation drivenFor language improvements it used Java 5 (java based configuration)Supported from Java 4 to Java 8

Q7. In how many ways can Dependency Injection be done?

There are three ways in which dependency injection can be done in the bean configuration file.

  1. Method Injection: In order to initiate the functions, the client uses an interface to provide dependency to the class. 
  2. Property injection: It is also known as setter injection. It uses public property to induce injection to the class. 
  3. Constructor injection: Using the client constructor injection it provides the dependency injection. 

Q8. In which scenario, you will use singleton and prototype scope?

Singleton is used when one instance of the bean definitions get instantiated in the spring container. A new request can only be made if the container has no other pending requests. 

Prototype scope allows one to make new instances for each request that gets passed. There is no need to wait for clearing of the container. Depending on what your requirement it is, you would pick one over the other. The injections can be mentioned in the bean configuration file. 

Q9. Differentiate between constructor injection and setter injection.

The table below draws the comparison between constructor injection and setter injection. Make sure you cover all the points in the interview questions spring. 

KeyConstructor InjectionSetter Injection
OrderingAn order needs to be followed for dependency injection. Uses a constructor based DIBased on the requirements, the setter injection is performed for the dependencies.
CircularCan’t allow this injectionCan’t allow this injection
Multi Thread EnvironmentMore safety in this environmentThere is no added layer of security here
Spring Code generationLibrary does not support it. Library is supported here
Use CasesMandatoryOptional

Q10. What are inner beans in Spring?

In Java, you can define a class inside of another class. Same is applicable for inner beans. A bean can exist within the scope of another bean for usage. 

Q11. What are the transaction management supports provided by spring?

There are different ways to handle the programmatic transaction management in Spring. Following are some types of transaction management staples. Note that some can be declarative transaction management related terms. 

  1. Programmatic: use the code to help you manage the whole system. There is high flexibility. However, it can be challenging to maintain. 
  2. Declarative: The business code remains separate from management. This will help you maintain the two separate portions with ease (with xml template). However, there is a lack of flexibility in this case.  XML based code can be written here.  The files are stored in a xml based configuration file. Also this is part of the declarative transaction management feature of spring. 

Q12. Are Singleton beans thread safe in Spring Framework?

Singleton bean threads are not always safe. They need to be used with precaution.The overuse of the same thread makes it unsafe. 

Q13.  How many types of IOC containers are there in spring?

Bean Factory container: A collection of beans is found in the bean definitions factory. Whenever the client calls, the bean is instantiated. IOC inversion of control really solidifies the bean factory containers.

Application Context: In the  IOC inversion of control application context is an interface, it is placed on top of the Bean Factory. 

Spring Interview Questions

Q14. What are the advantages of JdbcTemplate in spring?

While using Spring there is a great mechanism to connect with a database for the java code. The main functionalities for a JDBC template are – 

  1. It will enable timely clean up of data. Also, database connections are formed when code is executed. Which need to be released from time to time. The storage is done in a bean configuration file.
  2. It automatically converts the regular SQL exceptions to run time exceptions. 

Q15. Differentiate between BeanFactory and ApplicationContext

FeaturesBean FactoryApplication Context
Auto registrationNoYes
Message source accessNoYes

Q16. How can you inject a Java Collection in Spring? Give an example?

These are the following ways in which injection can be done using Java Collection. 

<props>Used for name-value pairs
<map>Used for name-value pairs
<set>Sets values without duplicates
<list>Sets values without duplicates

Q17. What are classes for the spring JDBC API?

The classes for spring JDBC API can be put into four packages.

  1. Core 
  2. Object
  3. Support
  4. Datasource

Q18. List some of the benefits of IoC.

  1. Decreases the quantity of code required in the application
  2. It is easy to test and deploy the code
  3. Can make changes in the factory design easily
  4. There is lazy loading functionality which improves the performance. 

Q19. How to inject a java.util.Properties into a Spring Bean?

Here is a sample code of xml configuration file that will enable us to inject a java.util.Properties. (to be saved in the spring configuration file)

Package com.softwaretesttips.tutorial.spring.xml

Import java.util.Properties;

Public class DatabaseConfig {
	private Properties properties;

	public void setProperties(Properties properties) { = properties;

	public Properties getProperties() {
		return properties;

Bean definition xml file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

	<bean id="configBean" class="com.softwaretesttips.tutorial.spring.xml.DatabaseConfig">
		<property name="properties">
				<prop key="driverClassName">com.mysql.jdbc.Driver</prop>
				<prop key="url">jdbc:mysql://localhost:3306/mydb</prop>
				<prop key="username">root</prop>
				<prop key="password">abcdxyz</prop>


Q20. How can you fetch records by spring JdbcTemplate?

Here are the steps that you can follow to fetch the records by spring jdbc template. 

Single Row Query

import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RowMapper implements RowMapper<person1> {
    public person1 mapRow(ResultSet rs, int rowNum) throws SQLException {
        person1 person1 = new person1();
        person1.setID(rs.getLong("identificaion number"));
        return person1;
    } // enables transaction management

Q21. Explain Spring Bean Autowiring?

It is important to declare the bean definition dependencies to enable autowiring. There are four different types or modes in which autowiring works :- 

  1. ‘No’
  2. ‘Name’
  3. ‘byType’
  4. ‘Constructor’

For a xml file configuration the default mode is set to ‘No.’ The default mode for java is ‘byType’

Spring Bean Autowiring
Spring Bean Autowiring

Q22. What is the advantage of NamedParameterJDBC Template?

Instead of traditional placeholders arguments, the ‘NamedParameterJDBCTemplate’ enables you to use parameters instead. It is easier to maintain and helps with readability. 

Q23. How configuration metadata is provided to the Spring container?

  1. Use XML configurations
<bean id="samplebean" class="my first.sample Bean definition">
<property name="name" value="myfirst"></property> // allows transaction management
  1. Autowired Annotation Based configuration
<context:autowired annotation-config/> // transaction management
//define the bean here
  1. Java based configuration
public class sampleBean
public sampleBean myfirst()
{ return new sampleBean(); }

Q24. What is the advantage of SimpleJdbcTemplate?

Uses both the JdbcTemplate and NamedParameterJdbcTemplate. There are some more advantages to using the SimpleJdbcTemplate. It has features like :-

  1. Autoboxing
  2. Varargs
  3. Generics to provide API
  4. JDK 5 or higher

Q25. How do you turn on annotation based autowiring?

Autowired annotation can be turned on by using the following steps:-

  • Step 1: Create a project and a package inside the src folder
  • Step 2: Add the libraries and add external JARs
  • Step 3: Create java classes
  • Step 4: configure a xml file
  • Step 5: Create java files and beans with configurations

Q26. Explain @Required annotation with example?

It is used for setter-injection. @Required is also a method level autowired annotation. Please refer to the below given code snippet to understand this better. Also declare it in the public class. 

This is possible due to the transaction management feature in the spring framework. Import org.springframework.beans.factory.annotation.Required;

public class Company {
    private Integer cid;
    private String cname;
    public void setpid(Integer [id) { //spring ioc container = pid;
    public Integer getpid() { // public class
        return pid;

Q27. What are the advantages of spring Aspect Oriented Programming?

Following are the advantages of spring AOP.

  1. It is not invasive
  2. Can be used to implement java (which is pure)
  3. Use of container system for dependency injections
  4. Implements cross cutting concern with no calls made to it directly
  5. Helps in regulation of cross cutters
  6. Can use XML configuration and @AspectJ annotation

Q28. What are the benefits of Spring Framework?

  1. Can deal with complex problems in JEE. It supports, manages and accommodates all functionalities of Java. 
  2. Promotes clean programming practices. 
  3. Can use in segregation or combination of other layers
  4. Can work with annotation based configurations 
  5. Can work with XML based configurations
  6. Containers are lightweight

Q29. What are the Aspect Oriented programming (AOP) terminologies?

Please find the list of AOP terminologies

  1. Aspect: it has APIs for cross-cutting
  2. Join Point: Used for adding a plug-in
  3. Advice: The action that has to be performed
  4. Pointcut: it is a group of join point 
  5. Introduction: Declaration of libraries, attributes and methods
  6. Target object: Also referred to as advice object
  7. Weaving: Linking of objects 

Types of Advice

  1. Before
  2. After
  3. After-running
  4. After-throwing
  5. Around

Q30. Define Bean Wiring.

When you decide to conjoin the beans with containers, the process is referred to as bean wiring. It defines the usage of dependency injection. 

Q 31. Does spring framework support all JoinPoints?

Yes, it is used to represent an execution of the method or function.

Q32. What are the different types of events in Spring framework?

Here is a list of events in spring framework

  1. A custom event
    1. Application
    2. Publisher
    3. Listener
  2. Asynchronous event
  3. Existing framework event
  4. Annotation driven event
  5. Generic support 
    1. Generic application event
    2. Listener
    3. Publisher
  6. Transaction bound event

Q33. What are the limitations with auto wiring?

Here is the list of disadvantages and limitations of auto wiring in spring while running web applications.

  1. Autowiring is not completely precise. It can cause ambiguity which is not handled by spring with ease. 
  2. The documentations of spring may not have access to autowired information
  3. Multiple beans with respect to their containers may get attached to the wrong constructor.
  4. Primitive classes and strings can not be autowired
  5. There are high chances of overriding with auto wiring in spring
  6. The definition of primitive data needs to be called out for auto wiring
  7. The high dependencies in the program can cause a lot of chaos and confusion

Q34. Difference between FileSystemResource and ClassPathResource?

File system resourceClass path resource
Path: spring-config.xml needs to be in the location of the projectPath: spring-config.xml needs to be in the src folder. 

Q35. What do you mean by Annotation-based container configuration?

Typically the spring configuration file can be written in two formats. One is XML based configuration and the other is annotation based. The annotations are used to declare a certain class, function, method or variable. Here is the list of annotations that are used in spring.

  1. @Required
  2. @Autowired
  3. @Qualifier
  4. JSR-250 annotations

Q36. What are the types of advice in AOP?

AOP is aspect oriented programming, the spring AOP has four different types of advice. It helps in interjection of a process. Programmatic transaction management in spring requires to implement advice in AOP. Here are the four types of advice used in aspect oriented programming for spring to run the web applications. 

  1. Before advice: Used before the execution of the program
  2. After returning advice: Used after the return statement
  3. After throwing advice: Used if an exception is thrown
  4. Around advice: During the execution, it is a combination of all the other three types of advice

Q37. How annotation wiring can be turned on in Spring?

The annotation wiring in spring has to be turned on explicitly. It is not a default function. Dependency injection has to be performed using annotations. It can be enabled through a spring configuration file. Once the configuration is completed, you can use the annotations to call the required function. 

Q38. Name some of the design patterns used in Spring Framework?

There are four design patterns widely used in the spring framework 

  1. Singleton pattern
    1. Singleton Beans
Singleton Beans
  1. Autowired singleton
  2. Factory method pattern
    1. Application context
    2. External context
Factory method pattern
Factory method pattern - External context
  1. Proxy pattern
  2. Template pattern

Q39. What’s the difference between @Component, @Controller, @Repository & @Service annotations in Spring?

Component in Spring

These are all used to detect spring beans automatically. More or less their functionalities are the same. Except @component can be used in the spring web MVC framework for definition of a controller. 

Q40. What do you understand by @Required annotation?

It is called as method level annotation in the spring framework. It is used for a setter method or function. It enables and mandates the setter injection. The value of the bean is injected during the configuration. 

Q41. What do you mean by @autowired annotation?

It is used to instruct and set the autowiring conditions in the spring frameworks. Helps in deciding where and how it will be used. It calls the autowire function. Dependency injection is implemented automatically. 

Q42. What is the target object?

The different types of advice are applied on what is called the target object. During the runtime an object is created which automatically overrides the existing capabilities. The object which automatically gets manifested after run time is referred to as the target object. 

Q43. What do you understand by @Qualifier annotation?

Sometimes, autowiring can lead to some conflicts. The resolution of such cases can be rectified using @Qualifier. 

Q44. What is spring IoC container and Dependency Injection?

Often objects rely on one another to do the job. In the case of inversion control (spring IoC container), this does not happen. Dependency injection is completed regardless of any object interference. It is used to apply the inversion control objectives.  IoC container typically controls the object dependencies in the spring aop. 

Q45. What are the modules of spring framework?

Here are the following modules in the spring framework. 

  • AOP
  • Spring IOC container (also known as inversion of control)
  • DAO
  • Context
  • WEB MVC framework- controller in spring mvc framework
  • ORM

Below is the photo depicting all the modules in the spring mvc framework

modules in the spring mvc framework

Q46. What do you understand by @RequestMapping annotation?

In order to handle the http requisition, the @RequestMapping annotation is used. The modules that deal with this are – MVC framework spring and REST. This annotation is used very often. 

Q47. Describe Spring DAO support?

The full form of DAO is – data access object. Helps in dealing with the ADO.NET, NHibernate etc, technologies. It helps in the integration of database connection and the object mapping. 

Q48. Does spring perform weaving at compile time?

Yes, all java based frameworks perform the task of weakening at the compile time. Spring Framework is no exception. It is one of the features of spring framework.

Q49. Name the exceptions thrown by the Spring DAO classes

  1. Remote Exception
  2. SQL Exception
  3. IO Exception
  4. Data Access Exception

Q50. What is the AOP Implementation?

Aspect oriented programming has the following implementations and concepts.

AOP Implementation

Q51. What is the front controller class of Spring MVC?

The front end of a web application has many requests floating in and out. This has to be controlled by the front controller class of the spring MVC. Dispatcher Servlet is known as the front controller in the spring MVC. 

Q52. What are the ways by which Hibernate can be accessed in Spring?

The two primary ways of handling hibernate using spring is:-

  1. Extend Hibernate DAO Support: AOP interceptor 
  2. Inversion control: Hibernate and call back

Q53. What does @Controller annotation?

It basically annotates the controller. The entire business logic is processed by this annotation. It resides in model view controller architecture. Which is the key to the entire program. 

Q54. What are the different ORM’s supported by Spring?

Here are the ORM’s supported platforms:-

  1. Hibernate
  2. JDO
  3. Toplink
  4. iBATIS
  5. JPA (Java persistence API)

Q55. What is the ViewResolver class?

View resolver gives a way to look at the view. MVC framework has the view resolver class which is used to retrieve models in the browser. There is no specific technology required to do this activity. The names are connected with their actual views. Following are some types of view resolvers.

  1. Internal Resource View Resolver
  2. XML View Resolver
  3. Resource Bundle View Resolver

Q56. Which ViewResolver class is widely used?

The internal resource view resolver is the most common and widely used view resolver. 

Q57. What do you mean by Aspect?

The aspect in AOP (aspect oriented programming) refers to the style of programming. This basically breaks down the program into parts called concerns. The concerns that are used across different applications are called the cross cutting concerns.

Q58. Does spring MVC provide validation support?

Spring MVC has the ability to validate client side and server side responses. Spring 4 onwards validation was placed in the framework.

Q59. Explain (Inversion of control) IoC Container in Spring Framework?

IoC container (also known as inversion of control) allows the flow of a program to be controlled by its objects which is unlike the traditional method of programming. Dependency injection allows the execution of the IoC container in the spring AOP framework. Here is the list for the advantages of the IoC container. 

  1. When a certain task is implemented, the execution is decoupled (loose coupling)
  2. Module centric design
  3. Contracts are made to understand what is going on in other modules
  4. Changes in one module do not affect the others
Inversion of control

Spring Interview Questions and Answers

Q60. Point out the difference between concern and cross cutting concerns in Spring AOP?

Concern is the behavior that one desires to implement in a given module. It is the functionality that gets executed for a given program. Cross-cutting concern is a concern that is carried out throughout the entire web application. 

Q61. What is the difference between Spring AOP and AspectJ AOP?

Spring AOP (aspect oriented programming)AspectJ AOP
Proxy based framework.Aspects are used in the main code
Proxies are created at the time when spring application startsIt is implemented before the execution begins.

Q62. What do you mean by Proxy in Spring AOP Framework?

There are two kinds of proxies in the spring AOP framework.

  1. Dynamic proxy
  2. CGLIB proxy

Q63. In Spring, what is Weaving?

The objects in a program need to be connected with the other objects across various modules. It is one of the most important features of spring framework. The combining and connecting process for objects is referred to as weaving in the spring framework. 

Q64. What is a Spring configuration file?

The configuration files help store the pattern in which the executions need to occur. The following are different types of configuration files that spring uses.

  1. XML config file
  2. Java based configuration file
  3. Annotation based configuration file

Q65. Can Spring 5 Integrate with the Jdk9 Modularity?

Yes Spring 5 can integrate with jdk9 modularity. This enables abstraction of packages. It is part of the java platform module system. 

Spring Interview Questions and Answers

Q66.Can Spring allow Spring MVC or Spring WebFlux in the same spring application?

Yes it permits the functioning of both Spring MVC and WebFlux inside the same spring application. 

Q67. Can Spring MVC run on Netty?

Yes, it is different from the traditional architecture. Therefore, spring MVC can run on netty as well. The spring boot runs on netty by default in most cases.

Q68. Can we have multiple Spring configuration files?

Yes different spring configuration files can exist in the spring framework. 

Q69. Define Mono and Flux types?

The reactive data types are referred to as Mono and Flux. Mono is used to handle the zero or 1 result. Whereas Flux is used for zero or more results. 

Q70. Define Spring Webflux?

There is a framework that sits on top of the project reactor, it is referred to as the spring Webflux. It is used to provide the asynchronous input and output message flows. It can be used to build APIs and other web application components. 

Q71. Can we send an Object as the response to the Controller handler method?

Yes, response objects need to be used in order to send the response to the controller in the spring web mvc. 

Spring Interview questions and answers 

Q72. Define Spring Webflux

Sometimes spring webflux is used in place of the spring web mvc. It is used to create asynchronous and non blocking loop execution. It is supported on jetty, tomcat, servlet

Spring Web Flux

Q73. Difference between the Web client and Webtestclient?

Web test client is reactive and non-blocking. This is used for testing the web application. Whereas, the web client uses the APIs to verify the response of the application. 

Q74. Do you think that Spring 5 is compatible with older versions of JAVA?

Spring 5 is compatible with Java version 9 and above. 

Q75. Does Spring Bean provide thread safety?

No, spring beans do not provide thread safety. 

Spring Interview questions and answers 

Q76. How can we use Spring to create a Restful Web Service returning JSON response?

Here are the steps that will help you create a restful web service returning JSON response. 

  1. Make a dynamic web project with the help of eclipse. 
  2. Then add the json utility to the classpath
  3. Change the required web.xml
  4. Then rename the xml file name ‘servlet.xml’ (Located in /WEB-INF folder)
  5. Create a bean with any desired name. 
  6. Create a controller with any desired name
  7. Build the maven
  8. Click run
  9. Use the run on server function
  10. Test the rest service
  11. Pass it as the URL parameters

Q77. How to achieve localization in Spring MVC applications?

We can utilize the Locale Resolver to achieve localization in the spring mvc applications. There is a requirement of two spring beans for this purpose. Session Locale Resolver will help in localizing predefined attributes.

Locale change interceptor can identify the parameters that exist within the http request. It also gives an opportunity to parametrize the properties for easy identification. 

Q78. How to create ApplicationContext in a Java Program?

Following are the most commonly used application context implementations :

  1. File System XML 
  2. Class path XML
  3. Web XML 

Here are the steps that need to be followed to create an application context

  1. Create a project with any desired name. Also, create a package in the src folder
  2. Add the spring libraries
  3. Create a java class
  4. Configure the spring beans in a file
  5. Create the content that you desire to run for the application

Q79. Please explain DispatcherServlet. 

It aligns to the concept of java spring beans configuration mechanism. It is the front controller of the system. It receives requests and delivers it to the controller which then sends the response. 


Q80. What are some of the best practices for Spring Framework?

  1. Avoid using the XML bean definition support
  2. Always use the java configuration
  3. Inside the domain class, do not use spring
  4. Scanning for the classpath is not required
  5. Use @autowire more often
  6. Make a good use of the spring test feature

Spring Interview questions and answers 

Q81. What is Reactive programming ?

Reactive programming is a type of paradigm that works with data flow or streams. It helps us use the arrays, emitters and functions. It helps in communication of dependencies across the different objects in the program. 

Reactive programming

Q82. What are the key features of reactive programming?

  1. Ease in implementation
  2. Can easily accommodate changes of algorithms
  3. Dynamic updation of values

Q83. List the concepts of reactive programming

  1. Degrees of explicitness
  2. Static/Dynamic
  3. Data flow
  4. High-order RP
  5. Evaluation programming models

Q84. What are the various approaches in reactive programming?

  1. Imperative: Simple equations that assign value can also become part of the reactive method of programming.
  2. Object orientation: OOPS concepts can also be implemented easily.
  3. Functional programming
  4. Rule based programming

Q85. What are the benefits of using Spring Tool Suite?

  1. Spring aware: it is tailor made for enterprise application. Easy to set up the spring boot and spring framework.
  2. The IDE agnostics: It gives you a plethora of options when it comes to choosing the coding environment. 
  3. Continuous launch of latest tools from time to time. 

Q86. Differentiate Mono and Flux

Use of single valueUse of more than single value
One resultInfinite results
Sample code:

public Mono <ITEM> find User() {    if (is Authenticated()) return Mono. just (new ITEM (“Pencil”, “Eraser”));    else return Mono. empty();}
Sample code:

public Flux<ITEM> All() {    return Flux.just(        new ITEM(“Pencil”, “Eraser”),        new ITEM(“Pen”, “Ink”)    );}

Spring Interview questions and answers

Q87. What is a JoinPoint?

Within an aspect there are some actions that occur during the execution. This is referred to as the join point. The picture below depicts join points. Such interview questions are best explained using a diagram. 


Q88. What is a MultipartResolver and when it’s used?

The multi part resolver is used to upload files. There are two types of resolvers in spring work. 

  1. Commons Multipart resolver
  2. Standard servlet multipart resolver. 

Q89. What is a Pointcut in Spring?

In your interview questions, this could be a very commonly asked question. While the advice is getting executed in a program, the point cuts are placed before the join point. Following are some ways to set the pointcuts in spring.

  1. @pointcut(“execution(**())
  2. @pointcut(“execution(

Spring Interview questions and answers

Q90. Differentiate between Dispatcher Servlet and Context Loader Listener

Features Dispatcher ServletContext Loader Listener
BeansControllers are usedServices and DAO are used
OptionalNo. Spring applications always require the dispatcher servletYes. Spring applications can survive without context loader listeners. 
ContainerCreates its own application contextIt is defined in the web.xml
Basic Request is sent to the spring mvc controllerReads the configuration text then parses it further

Q91. Differentiate JDK Dynamic Proxy and CGLIB Proxy

FeaturesJDK DynamicCGLIB Proxy
BasicA proxy to target class onlyProxy can be placed on sub classes as well
Package Within java3rd Party 
FinalNo proxy on final function and classNo proxy on final function and class
Use caseUsed for cases when implementations extends beyond one interfaceUsed when class can not be implemented at all.

Q92. What is Spring security? 

Spring security is an ideal framework that adds a layer of security to ensure that web applications are safe. It adds levels of authentication like SAML or Oauth/Oauth2 verification. It helps in masking and sealing the http requests. The penetration is secured by adding an extra layer of security. Below diagram depicts the features of spring security. 

Spring security

Q93. What are the advantages of spring framework?

  1. It is easy to test
  2. Lightweight application – can be easy on the systems performance
  3. Good abstraction
  4. Support is available at all times
  5. There is loose coupling. Loose coupling is often not found in other frameworks
  6. The templates are already predefined

Q94. Differentiate between “Save and Flush” and “Save” in Spring

FeatureSave and FlushSave
RepositoryJPA repositoryCurd repository
Bulk SaveNot supportedSupported
Data flush strategyDirectly flushed to DBNeed to call the flush explicitly
Data visibility post savingChanges are visible at all timesIt will not be visible outside
Use CaseWhen changes are made twice or more number of times for a single transactionWhen changes need not be accessed further. 

Q96. Draw a comparison between Spring servlet xml and application context xml

FeatureApplication Context xmlSpring Servlet xml
ReferencesSupports reference beans Supports reference beans across different xmls
ScanningFilters can be addedComponents need to be specified
BasicRefers to beans that are called in a single servlet. Refers beans related or connected to the given servlet

Q97. What is Spring boot?

It is placed on top of the entire framework. It basically gives a simple interface for the user to use the spring framework. It can help execute various types of applications mentioned below. 

Spring boot
Spring boot

Q98. What are the features of Spring Boot?

  1. It is opinionated: It figures out the functionalities by itself when faced with repetitive issues. 
  2. Can work standalone: It does not require additional plugins for running it.
  3. Auto configured: It need not be installed separately. It comes as a packaged environment. 

Q99. Is the Spring Boots configuration Intelligent? Explain briefly. 

Intelligent configuration directly points out to its main feature which is the auto configuration. Here is a diagram that depicts this.

Spring Boots configuration Intelligent

Q100. What is the process of starting a java based application using spring boot

process of starting a java based application using spring boot
  1. Package the application
  2. Select the type of server
  3. Configure the web server
  4. Get set for the deployment process
  5. Run it using the command – java-jar my-first-application.jar


These 100 spring interview questions will help you face your next spring interview. These interview questions range from basic to intermediate levels of questions that can be asked in your interview. If you are looking for a job in the IT support area, then you can check out our IT support Interview Questions.

Recommended Articles