What is Spring?
Spring is a powerful, open-source, lightweight, loose coupled, framework meant to reduce the complexity of developing applications.
Spring handles all the structure-related aspects which allow the developer to focus mostly on application development.
Some of the features of Spring are:
What is Spring Boot?
Spring Boot is an open-source, java-based framework that provides an easier and faster way to set up, configure and run production-ready Spring applications with a need for very few configurations.
Spring vs Spring Boot
The difference between Spring and Spring Boot is
The Sprint Boot Framework:
Mentioned some features of Spring Boot
Auto-Configuration - Starter Dependency - Spring Initializer - Easily builds the structure of the project Spring Actuator - Logging & Security Spring CLI
Spring Boot
Describe the feature Starter Dependency
Starter Dependency – With the help of this feature, Spring Boot bundles common dependencies together and eventually improves productivity and reduces the burden on having to look through code to find the dependencies needed for the project.
Some of the most used starter dependencies are;
Spring Boot
Describe the Spring Initializer feature
The Spring Initializer helps the developer to easily create the internal project structure so that the developer doesn’t have to manually set up the structure of the project.
With this feature, the developer can add mostly used dependencies, such as Spring Web, Thymeleaf, and Spring Boot DevTools.
SpringBoot
Describe the feature of Auto-Configuration
The Auto-configuration automatically configures the Spring application based on the jar dependencies that the developer added to the pom file.
For example, if the H2 database Jar is present in the classpath and we have not configured any beans related to the database manually, the Spring Boot’s auto-configuration feature automatically configures it in the project.
What is the @SpringBootApplication annotation?
The @SpringBootApplication annotation is used in the main class and is a combination of the
@Configuration
@ComponentScan
and
@EnableAutoConfiguration
What is the @EnableAutoConfiguration annotation?
The @EnableAutoConfiguration annotation auto-configures the beans that are present in the classpath and scans for components.
It’s a combination of the:
@Configuration
@ComponentScan
What do you mean by IoC (Inversion of Control) Container?
Inversion of Control transfers the control of an object to a container.
Some of the advantages are:
Spring container is the most important part of the Spring Framework.
The Spring container uses Dependency Injection (DI) for managing the application components by creating objects known as beans, configuring them, and managing their life cycles.
The instructions for the spring container to do the tasks can be provided either by Java annotations, or Java code.
What are the Spring Boot starters?
Spring Boot starters are dependency management providers that can be included in the application pom file.
These starters, make development easier and avoids developers having to go through sample code for commonly used dependencies.
A couple of Spring Boot starters are:
What is the difference between @Controller and @RestController?
The @Controller is a specialization annotation of the Component class.
The @RestController is a special version of the @Controller. It combines @Controller and @ResponseBody and simplifies the controller implementation.
Therefore, the @ResponseBody is not required.
How does the @ResponseBody annotation works
The @Response annotation enables serialization of the object into the HttpResponse
Why should we use Spring Booth?
We should use Spring Boot because:
Advantages of Spring Boot
What are Spring Boot limitations
The only one I know is that it can use dependencies that are not going to be used in the application. These dependencies increase the size of the application.
Can you describe in very simple steps the process of how the application works?
What is the @RequestMapping annotation?
The @RequestMapping annotation is one of the most commonly used annotations in Spring Boot.
It is considered a class-level annotation, however, the benefit of this annotation is that it can be applied to the controller class as well as methods.
The @RequestMapping annotation is the base path of the request into the controller, and the developer can apply additional method-level annotations to make mappings more specific to handler methods.
What are Spring Annotations?
Spring annotation is a form of metadata that provides data about a program.
Describe the @Required annotation
The @Required is a method-level annotation to the setter method of a bean property and making the setter-injection mandatory.
This annotation indicates that the required bean property must be injected with a value at the configuration time.
public class Company {
private Integer cid; private String cname;
@Required. ******************
public void setCid(Integer cid) {
this.cid = cid;
}
public Integer getCid() {
return cid;
}..... }
Describe the @Autowired annotation
It is used to autowire spring beans on setters, instance variables, and constructors.
The spring container auto-wires the bean by matching the data type.
What are the 5 Core Spring Framework annotations?
@Autowired @Configuration @ComponentScan @Bean @Required
What are the 4 Spring Framework Stereotype annotations?
@Component - Advising Spring to manage the bean
@Controller - Receives HTTP requests
@Service - Business logic
@Repository - Data storing
What are the 2 Spring Boot Annotations?
@SpringBootApplication
@EnableAutoConfiguration