Are you preparing for an interview where the Spring framework is the main part of the tech stack? Here, we have curated a list of popular Spring interview questions and answers that you must go through before appearing for your job interview. This blog will provide the latest spring interview questions all in one place and ensure that you ace your Spring framework interview. For your convenience, we have categorized the Spring interview questions under the following topics:
Table of Contents:
- General Spring Interview Questions
- Spring Beans Interview Questions
- Spring AOP Interview Questions
- Dependency Injection/ IoC Interview Questions
- Spring Annotations Interview Questions
- Spring Data Access Interview Questions
- Spring MVC Interview Questions
- Spring Boot Interview Questions
General Spring Interview Questions
Q1. Name different components of a Spring application.
Ans. A Spring application has the following components:
- Interface – Defines functions
- Bean class – Consist of properties, its setter and getter methods, functions, etc.
- Spring Aspect-Oriented Programming (AOP) – Provides the functionality of crosscutting concerns
- Bean Configuration File – Consists of classes information and the ways to configure them
- User program – Uses functions
|Top Java Courses||Top Other Programming Languages Courses|
Q2. What is a Spring configuration file?
Ans. The Spring configuration file is an XML file. It has information about the classes, interfaces, and their dependencies. It suggests how classes are configured and introduced to each other. Spring Configuration file is very useful in managing projects if planned correctly.
Q3. Name various ways to use the Spring Framework.
Ans. Spring Framework can be used as –
- Full-fledged Spring web application
- Third-party web framework, using Spring Frameworks middle-tier.
- Enterprise Java Bean that can wrap existing POJOs (Plain Old Java Objects)
- Remote usage
Q4. What are the benefits of Spring?
Ans. The various benefits of Spring include –
- It is versatile and non-invasive
- Spring supports dependency injection and offers multiple modules to achieve different functionality for the development of the application.
- It allows developers to develop enterprise-class applications using POJOs.
- Spring can remove the creation of factory classes.
Q5. How can a Spring file be converted to Java?
Ans. A Spring file is converted to Java by using Spring’sClassPathXmlapplicationContext from Java to set the Spring configuration.
Q6. What are the different features of the spring framework?
Ans. Following are the different features:
- Transaction Management
- Inversion of Control
- MVC framework
- Aspect-Oriented Programming
Also Read: Top Java Interview Questions & Answers
Q7. What are the different types of transaction management?
Ans. There are two types of transaction management supported by Spring, that include –
- Programmatic transaction management
- Declarative transaction management
Q8. What are some of the vital Spring modules?
Ans. Some of the vital Spring modules are:
- Spring AOP
- Web Module
Q9. How can you configure Spring into the application?
Ans. There are three ways to configure Spring into the application, which are –
- Java-based configuration
- XML based configuration
- Annotation-based configuration
Q10. How is Spring Java different from Node JS?
Ans. Following are some key differences between Spring Java and Node JS:
|Blocking I/O and users must wait for every I/O request||Applications are non-blocking I/O (Input/Output model) and asynchronous|
|Multi-threaded hence tasks are performed simultaneously||Single-threaded hence works on the concept of one request one thread|
|Expensive as requires multiple threads||Not as expensive|
Q11. Is it possible to have multiple Spring configuration files?
Ans. Yes, it is possible to define multiple spring context configuration files through ContextConfigLocation. It can consist of multiple locations and can be separated by commas and spaces.
Further, it is also possible to define multiple root level spring configurations or import elements in the context configuration files.
Want to learn or test your PHP skills for an interview? Here are some of the most common and frequently asked PHP Interview Questions and Answers with detailed answers.
Q12. Which channels does Spring 2.0 support?
Ans. Spring 2.0 supports the following channels –
- Direct Channel
- Executor Channel
- Pollable Channel
- Priority Channel
- PublishSubscribe Channel
- Queue Channel
- Rendezvous Channel
- Scoped Channel
- Subscribable Channel
Q13. What are the new features in Spring 4.0?
Ans. Different features of Spring 4.0 include –
- It manages the Spring Bean lifecycle like JNDI lookup.
- It is used to create web applications and web services.
- All annotations are used to create custom composed annotations.
- It supports WebSocket-based communications in all web applications.
Q14. What do you mean by the introduction?
Ans. The introduction enables the user to add new attributes and methods to existing classes.
Q15. Name different editors used in Spring Framework.
Ans. Different editors used in Spring Framework include –
Q16. How can you control the database connection?
Ans. Database connection can be controlled by using the following classes –
- AbstractData Source
- Data Source Utils
- DataSource TransactionManager
- DriverManager DataSource
- SingleConnection DataSource
- SmartData Source
- TransactionAware DataSourceProxy
Q17. What is a Property Editor?
Ans. A property editor is a feature of the JavaBeans API. This feature enables the conversion of property values to and from text values.
Q18. What is the Web Module?
Ans. The web module provides basic web-oriented integration features and helps to create a web application without XML. After using the web module, a web.xml file needs to be configured.
Q19. What is Reactive Programming?
Ans. Reactive programming is a non-blocking, asynchronous, and event-driven application. It requires a small number of threads to scale. It has a backpressure mechanism. The backpressure is on the key ingredient that ensures that the producers do not overwhelm consumers.
Q20. What are the advantages of Reactive Programming?
Ans. The following are some of the advantages of Reactive Programming:
- Helps to increase the utilization of computing resources, such as multicore and multi-CPU hardware.
- Complex threading becomes very easy
- Helps to increase the performance by a reduction in the serialization process.
- Easy to implement back-pressure
Spring Beans Interview Questions
Q21. What is a Spring Bean?
Ans. Spring Bean is a crucial concept of the Spring Framework. Objects that form the base of any application and those managed by the Spring IoC container are called beAns.
Q22. Why is the Spring bean configuration file necessary?
Ans. Spring Bean configuration file can be used to define all the beans initialized by Spring Context. Spring Bean configuration file reads and initializes the Spring bean XML file when the instance of Spring ApplicationContext is created. These files can then be used to get different bean instances once the context is initialized.
Q23. What are Inner Beans?
Ans. If a bean is using the property of another bean, it can be called an inner bean. Spring’s XML based configuration metadata defines the use of <bean> element inside the <property> or <constructor-arg>. Inner beans are anonymous.
Q24. What is Bean Wiring?
Ans. If beans get combined within the Spring container, the structure is known as bean wiring. These beans are usually combined by using the dependency injection method.
Q25. What is Bean Factory?
Ans. Bean Factory is a Lightweight container that loads bean definitions and manages beAns. These beans are configured using an XML file and manage singleton-defined bean.
Q26. What are the different ways of controlling the life cycle events of a bean?
Ans. There are 2 ways for controlling the life cycle events of a bean –
- InitializingBean and DisposableBean interfaces
- Init-method and destroy-method
Q27. Are Spring singleton beans thread-safe?
Ans. No, Spring singleton beans are not thread-safe.
Q28. What is Autowiring?
Ans. Autowiring is a crucial feature in the Spring framework, which uses setter or constructor injection and allows the user to inject the object dependency implicitly.
Q29. How many types of Spring Bean auto wiring are there?
Ans. Spring framework has four types of auto wiring –
- autowire byName
- autowire byType
- autowire by constructor
- autowiring by @Autowired and @Qualifier annotations
Q30. What are the limitations with auto wiring?
Ans.The following are the limitations with auto wiring:
- Overriding possibility: Dependencies can be specified using <constructor-arg> and <property> settings. It will always override autowiring.
- Primitive data type: The primitive data types String or Integer using property or constructor-args tag need to be defined. These tags cannot be autowired.
- Confusing Nature: If there is a lot of dependency in a program, then it will be hard to find using autowire attribute of the bean. Always prefer using explicit wiring because autowiring is less precise.
Q31. Mention the five bean scopes supported by Spring?
Ans. Following are the five bean scopes:
Q32. What are Singleton Scopes used with?
Ans. Singleton Scopes are used with Stateless session bean.
Q33. Explain Bean Lifecycle.
Ans. The bean lifecycle defines the path of bean initiation and lasts till bean completion. It is managed by spring containers as all the spring containers start as soon as the program is initiated. Further, as per the request, it creates an instance of a bean and then injects the dependencies. Once this process is done, the bean is being destroyed as soon as the spring container is closed.
Below is the bean lifecycle flow:
Container started → bean instantiated → dependencies injected → custom int() method → custom utility method → custom destroy() method
Also Read: Top Python Interview Questions and Answers
Spring AOP Interview Questions
Q34. Name some AOP concepts.
Ans. Different types of AOP concepts are –
- Target object
- AOP proxy
Q35. Name the types of advice in AOP.
Ans. There are five types of advice in AOP –
- Throws advice
- Around advice
- After returning advice
- Before advice
- After advice
Q36. What is the AOP module?
Ans. Aspect-Oriented Programming (AOP) is a key component of the Spring framework. It allows interceptors to intercept an application. It can also be defined as the breaking of codes into different modules.
Q37. What is weaving?
Ans. Weaving is a process of applying aspects to the target object or other application types to create an advised object or a new proxy object.
Q38. On what points can you apply weaving?
Ans. We can apply weaving on the following points –
- Compile Time
- Class load Time
Q39. Name some of the types of Autoproxying.
Ans. Different types of AutoProxying are:
- Metadata autoproxying
Q40. Explain JoinPoint.
Ans. JoinPoint showcases a point in an application where we can plug in an abstract-oriented programming aspect. This is the actual place where actions will be taken with the help of the Spring AOP framework.
Looking to expand your IT skills and knowledge? Here is a curated list of Top Online IT Courses that will improve your IT skills and career prospects.
Dependency Injection/ IoC Interview Questions
Q41. What is Dependency Injection?
Ans. Dependency Injection is one of the important functionalities of Spring IoC (Inversion of Control) and is responsible for injecting dependencies through different processes, either through the Constructor or Setter method. Dependency Injection also ensures loose coupling between the classes.
Q42. What are the different types of Dependency Injection?
Ans. Dependency Injection is of three types –
- Constructor injection – Here a class constructor provides dependencies
- Setter injection – Here, the client exposes a setter method used by the injector to inject the dependency.
- Interface injection – Here the injector method provides dependency
Only constructor and setter injections are used in the Spring framework.
Q43. What are the benefits of using IoC?
Ans. The primary benefits of IoC include –
- Minimizes the number of codes in any application
- Makes a platform/application easy to test, as it doesn’t need singletons or JNDI lookup mechanisms
- Promotes loose coupling with fewer efforts and intrusive mechanism
- Facilitates Eager Instantiation
Q44. Can you inject an empty string value?
Ans. Yes, we can inject an empty string value as the default value.
Q45. What do you mean by loose coupling?
Ans. Coupling is associated with collaboration, and it is basically of two types – tight coupling and loose coupling.
Loose Coupling – It refers to the concept of removing one object’s dependency on another object (ClassX’s dependence on ClassY). It generally helps in:
- Improving test-ability
- Following GOF principle
- Swapping pieces of codes and objects
Tight Coupling – This form of coupling refers to the concept where when one object is changing, the other one is also compelled to change.
Q46. What is the difference between constructor injection and setter injection?
Ans. The differences between constructor injection and setter injection are:
|Constructor Injection||Setter Injection|
|No partial injection.||Partial injection can be present.|
|It does not override the setter property.||It overrides the constructor property.|
|A new instance is created if any modification is done.||New instance is not created if any modification is done.|
Q47. State difference between BeanFactory and ApplicationContext.
Ans. Spring involves two different IoC containers naming BeanFactory and other is ApplicationContext: Below are some key differences between both of the IoC containers:
|No support for Annotation based dependency injection||Supports annotation|
|Does not supports publishing event to beans||Supports publishing event to beans|
|Does Not support internationalization||Supports internationalization|
|Slow loading||Fast loading|
Q48. What is DataAccessException?
Ans. DataAccessException is an unchecked RuntimeException. It is used to handle the errors occurring when the details of the database access API are being used.
Q49. How will you access Hibernate using Spring?
Ans. We can access Hibernate using Spring via two ways –
- Inversion of Control with a Hibernate Template and Callback
- Extending HibernateDAOSupport and Applying an AOP Interceptor node
Q50. What is the procedure to provide configuration metadata to the Spring Container?
Ans. Following are three important methods to provide configuration metadata to the Spring Container:
- Annotation-based configuration
- XML based configuration file
- Java-based configuration
Q51. What is the procedure to inject a Java Collection?
Ans. Following are the different types of configuration elements:
- The <set> type is used to inject a set of values without any duplicate values.
- The <list> type is used to inject a list of values, in this case, duplicates are allowed.
- The <props> type can be used to inject a collection of name-value pairs, in this case, both name and value should be Strings.
- The <map> type is used to inject a collection of name-value pairs, in this case, name and value can be of any type.
Explore popular Java Courses, Skills & Careers, read our blog – what is Java?
Spring Annotations Interview Questions
Q52. What are some of the important Spring annotations?
Ans. List of some of the Spring annotations are:
- @Service is used to indicate a class as a Service.
- @Scope is used to configure the scope of the spring bean.
- @Configuration is used to indicate that the class can be used as a source of bean definitions by the Spring IoC container.
- @ComponentScan is used to scan all the classes available under a package.
- @Required used to indicate the affected bean property that must be populated at configuration time, by an explicit property value in a bean definition or with the help of autowiring.
- @ResponseBody is used to send an object as a response, basically used for sending XML or JSON data as a response.
- @PathVariable is used to map dynamic values from the URI to handler method arguments.
- @Autowired is used for autowire bean on the setter method similar to @Required annotation, on the constructor, on a property, or on methods with arbitrary names and/or multiple arguments.
- @Component is used to indicate a class as a component, where all the classes are used for auto-detection and composed as a bean when annotation-based configurations are used.
- @Controller is used for MVC applications and is generally used with @RequestMapping annotation.
- @Repository annotation indicates that a component is used as a mechanism to store/retrieve/search data.
- @Qualifier is used for wiring a single bean with a property at a time when there are multiple beans of similar type with the help of @Autowired annotation
- @Bean is used in java based configurations, where a method annotated with @Bean will return an object that should be registered as a bean in the Spring application context.
Q53. Can you name different types of events of Listeners?
Ans. Yes, there are three types of events of listeners:
- ContextClosedEvent – When the context is closed.
- ContextRefreshedEvent – When the context is initialized or refreshed
- RequestHandledEvent – When the web context handles a request
Q54. What is the annotation-based (@AspectJ based) aspect implementation?
Ans. The given implementation case (@AspectJ based implementation) leads to a style of declaring aspects as regular Java classes annotated with Java 5 annotations.
Q55. How to go ahead with exceptional handling in Spring?
Ans. There are multiple ways to handle exception in Spring and some of them are:
- Controller-based annotation method using @ExceptionHandler annotation
- Global Exception Handler along with @ControllerAdvice annotation
- HandlerExceptionResolver implementation for creating global exception handler
Q56. How to send an email by using Spring Framework?
Ans. The JavaMailSenderImpl annotation of Spring helps in easily sending emails from Java. This JavaMailSenderImpl produces a JavaMailSender interface and supports:
- JavaMail API’s MimeMessages
- Spring’s SimpleMailMessage
Further, it allows the class to pre-define the mail settings pre-configure JavaMail Session. The below steps will help in sending an email using the Spring framework:
- In ApplicationContext.xml – Configure JavaMailSenderImpl as Spring bean
- With JavaMailSenderImpl reference, configure the test application
- Create a Java application to send an email
Note: If you are not very comfortable with writing Spring configuration file, you can sign-up for Spring online course like Spring Framework 5: Beginner to Guru on Udemy as it thoroughly covers Spring Framework concepts)
Q57. How are The Spring @Controller and @RestController Annotations different from each other?
Ans. Below are the differences:
|A very traditional Spring controller||Introduced in Spring 4.0 to offer effective RESTful web services.|
|Includes only the components of @Controller||Combines @Controller and @ResponseBody|
|Designates the bean class||Eliminates annotation needs for handling every request of the controller class|
Q58. Is it possible to send an object as the response of the Controller handler method?
Ans. Yes, it is possible to send JSON or XML based response in restful web services, with the help of @ResponseBody annotation.
Preparing for a Java interview? Here are the Top Java Interview Questions and Answers to boost your interview preparation.
Data Access Interview Questions
Q59. What is Spring DAO?
Ans. In Spring, DAO stands for Data Access Object which is a design pattern that provides an abstract interface to some type of database. The basic objective of DAO is to ease the data access technologies including JDBC and Hibernate. It offers data operations without exposing the exact database details. Further, a DAO pattern is used to perform CRUD operations.
Explore Popular Database Courses on Naukri Learning
Q60. Name some classes present in spring JDBC API?
Ans. The following are some of the important JDBI API classes:
- NamedParameterJdbc Template
- Jdbc Template
- SimpleJdbc Template
Q61. What is the possible way to fetch records by Spring JdbcTemplate?
Ans. The following are the two interfaces that can be used to fetch records from the database:
Q62. How is Spring JDBC different from plain JDBC?
Ans. Spring JDBC is a value-add provided by the Spring Frameworks on the top JDBC layer. It is an abstraction layer on top of JDBC technology. Spring JDBC does the following:
- Do the work for each iteration
- Prepare and execute the statement
- Process any exception
- Define connection parameters
- Handle transactions
- Set up the loop to iterate through the results (if any)
- Open the connection
- Specify the statement
- Close the connection
Q63. What ORM’s are supported by Spring?
Ans. Spring supports the following ORM’s:
- JPA (Java Persistence API)
- JDO (Java Data Objects)
Q64. How would you access hibernate with the help of Spring?
Ans. There are two ways to hibernate using Spring:
- By extending hibernateDaoSupport and spreading over an AOP interceptor
- By inversion of control (IOC) with a HibernateTemplate and Callback
Q65. How is the context:annotation-config and context:component-scan different from each other?
Ans. Both of context:annotation-config and context:component-scan are the two different XML configuration elements of Spring.
<context:annotation-config> is used for:
- Activating annotations in beans that are registered in the application context
- Activating dependency injection annotations
- Resolving dependencies like @Autowired, @Qualifier, @PostConstruct, @PreDestroy, and @Resource
<context:component-scan> is used for:
- Identifying the right packages which need to be scanned and find annotated beans or components
- Detecting @Component, @Repository, @Service, @Controller, @RestController, and @Configuration
MVC (Model-View-Controller) Interview Questions
Q66. What is Spring MVC?
Ans. Spring MVC follows the Model-View-Controller design pattern and implements basic features of a core Spring framework, including Inversion of Control and Dependency Injection.
Q67. How is the DispatcherServlet used in Spring MVC?
Ans. The DispatcherServlet is a popular Spring MVC web framework that acts as Front Controller. A Front Controller receives all the information related to incoming requests and further delegates this request to other components (@Controller annotation & InternalResourceViewResolver class).
Also, it is noticeable that a DispatcherServlet aptly handles incoming requests and forwards them to the right Controller depending upon its actual role. It also plays a crucial role in activities like:
- View resolution
- Error handling
- Locale resolution
- Theme resolution
Q68. Give steps to configure DispatcherServlet in Spring.
Ans. Steps to configure DispatcherServlet in Spring:
<!–Defaults to ABC.xml –> <param-value>ABC.xml
Want to upskill yourself to build a successful career? Check out the Most In Demand Tech Skills.
Q69. What is the procedure to upload files in the Spring MVC Application?
Ans. Spring MVC Application provides built-in support to upload files by using MultipartResolver interface implementations. Here, a validator is used to check the file uploads in the field, which should consist of a size greater than zero. In the end, there is a simple view that consists of a form with the option to upload a file.
Q70. How do you validate from data in Spring Web MVC Framework?
Ans. There are three ways to implement validation:
- By using annotation
- By using both functions
Q71. What is a RowCallbackHandler?
Ans. RowCallbackHandler is an interface used by JdbcTemplate to process rows of a ResultSet. It processes rows on a per-row basis.
Q72. What is ViewResolver class?
Ans. The ViewResolver class offers to map between view names and actual views. It also allows the user to set properties like prefix or suffix to the view name.
Q73. Which would you consider, Play framework or Spring MVC?
Ans. I would go with Spring MVC for these reasons:
- Availability of ample resources on Spring MVC.EBOOK
- It renders a very clean division among views, controllers, and JavaBean models.
- Truly view-agnostic
- It has a better testable code and ensures better integration with view technologies.
Spring Boot Interview Questions
Q74. What do you mean by Spring Boot?
Ans. From the Spring umbrella, a Spring Boot is a Java-based framework that helps in creating microservices that helps in building stand-alone spring applications that are production-ready. Some of the advantages of using a Spring Boot framework are:
- Eases the process of developing spring applications
- Boosts productivity
- Reduces development time of application
- Offers flexibility to configure with XML and Java Beans
Q75. Differentiate between SpringBoot and Spring MVC.
Ans. The differences between SpringBoot and Spring MVC are:
|It is a way to ease the creation of a stand-alone application with basic configurations||Spring MVC is a module of Web-Servlet which is used for implementing a web application|
|It offers a unique feature like auto-configuration of application||It is equivalent to JSF(Java Server Faces) in the JavaEE stack|
|SpringBoot offers embedded HTTP servers such as Jetty, Tomcat for creating executable files||It has an equivalent @RestController for implementation of REST|
Q76. What are the features of Spring Boot?
Ans. The following are the features of Spring Boot:
- Spring Initializer
It is a tool that bootstraps the spring boot projects. Spring Initializer enables a developer to create an internal project structure. It enables developers to select a project, the programming language of choice, and add dependencies such as dev tools, actuator, and web. While using this feature, the developer will not have to manually set up the structure of the project.
- Spring Boot CLI
It is a command-line tool that allows you to develop a Spring application quickly. Spring CLI lets you execute Groovy scripts, so you can code by using your knowledge of Java, without writing reusable code repeatedly.
- Starter Dependency
This feature enables Spring Boot to aggregate common dependencies together and improve productivity.
Auto-Configuration helps you to configure your Spring Boot application automatically. While creating a new project, Spring Boot allows you to choose dependencies for your project. Based on these dependencies, the autoconfiguration feature loads specific default configurations.
- Externalized Configuration
It means using the application code that you use in one environment in an external environment. Externalized configuration feature lets you reuse your code in diverse environments.
Q77. What are the advantages of using Spring Boot for application development?
Ans. The advantages of using Spring Boot for application development are:
- Apps developed using spring boot are easier to launch. It helps to create applications that can be started using java.jar.
- Spring boot offers pinpointed ‘started’ POMs to Maven configuration.
- It provides a variety of plugins to develop and test Spring Boot applications easily using Build Tools like Maven and Gradle.
- It has the provision to embed Undertow, Tomcat, Jetty, or other web servers directly. You don’t need to deploy WAR files.
- Offers production-ready support like monitoring.
- It avoids writing lots of boilerplate Code, Annotations, and XML Configuration.
- Easy to integrate Spring boot application with its Spring ecosystems like Spring JDBC and Spring Security.
Q78. What are the different ways to create a Spring Boot application using Maven?
Ans. The following are some of the ways to create a Spring Boot application using Maven:
- Spring Boot CLI
- Spring Initializr
- Spring Starter Project Wizard
- Spring Maven Project
Q79. Explain Spring Boot starters.
Ans. Spring Boot starters are a set of dependency descriptors that you can include in your application to enable dependencies. The starters contain many dependencies that you need to get a project up and running quickly. Spring Boot provides several starters that allow us to add jars to the classpath. Some of the Spring Boot starters under the org.springframework.boot group are:
- spring-boot-starter – It is the core starter that includes logging, auto-configuration support, and YAML.
- spring-boot-starter-artemis – for JMS messaging with Apache Artemis
- spring-boot-starter-data-jpa – for Spring Data JPA with Hibernate
- spring-boot-starter-data-couchbase – for the Couchbase document-oriented database
- spring-boot-starter-web-services – for Spring Web Services
- spring-boot-starter-thymeleaf – to build MVC web applications using Thymeleaf views
- spring-boot-starter-data-ldap – for Spring Data LDAP
- spring-boot-starter-security – for Spring Security
Q80.What is the use of @SpringBootApplication annotation?
Ans. The @SpringBootApplication annotation is a combination of three Spring annotations, namely @Configuration, @ComponentScan, and @EnableAutoConfiguration. It offers the features of all three annotations with just one line of code. It enables developers to use a single annotation instead of multiple annotations, which results in fewer lines of code.
The @SpringBootApplication annotation offers a host of functionalities through the following three Spring annotations:
It marks a class as a Configuration class for Java-based configuration.
It allows component scanning so that the web controller classes and other components that are created will be automatically discovered and registered as beans in Spring’s Application Context. This annotation discovers all the @Controller classes you write.
It enables Spring Boot to auto-configure the application context.
Q81. What is Thymeleaf?
Ans. Thymeleaf is a server-side Java template engine used for creating web applications. It offers various template modes including HTML, XML, CSS, and text. Thymeleaf can be integrated with Spring Framework. Spring Boot offers auto-configuration for Thymeleaf by adding the spring-boot-starter-thymeleaf dependency.
Preparing for an HTML interview? These Top HTML Interview Questions and Answers will help you crack your HTML interviews.
Q82. How to deploy Spring Boot Applications to an external Tomcat server?
Ans. To deploy your Spring Boot application to an external tomcat server, you will need to do the below changes:
- pom.xml – add dependency and packaging to war
- Extend the main class with SpringBootServletInitializer and override its configure method
- Generate WAR and deploy to the external server
Q83. How to use jetty instead of tomcat in spring-boot-starter-web?
Ans. We can use jetty instead of tomcat in spring-boot-starter-web by replacing the existing dependency.
Step 1: Find the following dependency:
Step 2: Replace it with:
Step 3: Add Jetty:
All the Best for your interview and watch out this space for more Spring interview questions and answers!
If you have recently completed a professional course/certification, click here to submit a review and get FREE certification highlighter worth Rs. 500.