2. Spring Flashcards
(72 cards)
What is the Spring Framework?
The Spring Framework is an open-source application framework for Java that provides comprehensive infrastructure support for developing Java applications. It is designed to simplify Java development and promote good programming practices.
What are the main features of the Spring Framework?
The main features of the Spring Framework include dependency injection, aspect-oriented programming, transaction management, model-view-controller (MVC) architecture, and integration with various data access technologies.
True or False: Spring uses the Inversion of Control (IoC) principle.
True
What is Dependency Injection (DI) in Spring?
Dependency Injection is a design pattern used in Spring to manage dependencies between objects. It allows objects to be injected into a class, rather than the class creating its own dependencies, promoting loose coupling and easier unit testing.
Fill in the blank: The Spring container is responsible for managing the __________ of application objects.
lifecycle
What are the two main types of Spring containers?
The two main types of Spring containers are the BeanFactory and the ApplicationContext.
What is the role of the ApplicationContext in Spring?
The ApplicationContext is a more advanced container than BeanFactory. It provides additional features such as event propagation, declarative mechanisms to create a bean, and support for internationalization.
What is Aspect-Oriented Programming (AOP) in Spring?
Aspect-Oriented Programming is a programming paradigm that allows separation of cross-cutting concerns, such as logging and transaction management, from the main business logic. Spring AOP provides support for defining and applying aspects.
Which annotation is used to define a Spring bean?
@Component, @Service, @Repository, and @Controller are annotations used to define Spring beans.
What is the purpose of the @Autowired annotation?
The @Autowired annotation is used for automatic dependency injection in Spring, allowing Spring to resolve and inject collaborating beans into a class.
What is the Spring MVC framework?
Spring MVC is a web framework that is part of the Spring Framework, providing a model-view-controller architecture for developing web applications. It separates the application into three interconnected components: the model, the view, and the controller.
True or False: Spring supports both XML and Java-based configuration.
True
What is the purpose of the @RequestMapping annotation?
@RequestMapping is used to map web requests to specific handler methods in a controller class in Spring MVC.
What does the Spring Boot project provide?
Spring Boot is an extension of the Spring Framework that simplifies the setup and development of new Spring applications by providing a set of defaults, auto-configuration, and embedded servers.
Fill in the blank: Spring Boot uses __________ to simplify dependency management.
starters
What is the purpose of Spring Data?
Spring Data provides a consistent approach to data access and manipulation, allowing developers to work with various data sources, including relational databases, NoSQL databases, and more, using a common programming model.
What is the difference between @Controller and @RestController?
@Controller is used to define a controller in Spring MVC that returns views, while @RestController is a convenience annotation that combines @Controller and @ResponseBody, indicating that the controller will return data directly rather than views.
What is a Spring Boot starter?
A Spring Boot starter is a set of convenient dependency descriptors that can be included in a Spring Boot application to simplify the configuration and setup of common functionalities.
What is Spring Security?
Spring Security is a powerful and customizable authentication and access control framework for Java applications, providing comprehensive security features for both web and enterprise applications.
True or False: Spring supports reactive programming.
True
What is the purpose of the @Transactional annotation?
The @Transactional annotation is used to define the scope of a single database transaction, allowing developers to specify transactional behavior for methods in Spring applications.
What is the Spring Boot Actuator?
Spring Boot Actuator provides built-in endpoints for monitoring and managing Spring Boot applications, exposing metrics, health checks, and application information.
What is a Bean in Spring?
A Bean in Spring is an object that is instantiated, assembled, and managed by the Spring IoC container. Beans are the backbone of a Spring application.
What is the purpose of the @Value annotation?
@Value is used to inject values into Spring beans from property files, environment variables, or system properties.