Spring Core Flashcards

1
Q

What are Spring Projects?

A

Application frameworks that provide solutions to issues faced by enterprise applications. An example is Spring Boot, a popular framework to develop microservices.

Other Spring Projects: Spring Cloud, Spring Data, Spring Integration, Spring Security

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Spring Modules?

A

Spring Modules are the building blocks of Spring Projects and Spring Framework. They are what you see when you look under the hood of Spring Projects.

An example of an important container of modules is the Spring Core container, which holds the core, beans, context, and expression language modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is IOC?

A

IOC- Inversion of Control, is when Spring frameworks take control of creating objects & injecting dependencies into your code. It is implemented by the Core Container.

It is helpful in achieving loose coupling between classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is dependency injection? Benefits?

A

A technique in which an object receives other objects/ “dependencies” that it needs to run.
*The code that passes dependencies to an object is called the ‘injector’.

Benefits:

  • allows for loose coupling of components
  • puts responsibility of managing them onto container
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Types of dependency injection Spring supports

A

Constructor:

  • more secure, dependencies required
  • enables implementation of immutable objects

Setter injection:

  • allows partial dependencies
  • easily change values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Spring Bean life-cycle?

A

Container started -> bean instatiated -> depenedencies injected -> container is closed -> bean is destroyed.

Management of beans is conducted by the BeanFactory or Application Context

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Bean Factory?

A
  • an interface that is a container for instantiating, configuring, and managing beans
  • loads on-demand (more lightweight) based on a configuration file or using Java Configuration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Application Context?

A
  • implements the BeanFactory interface

- the central interface within a Spring app, used for providing configuration info to the app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is bean wiring?

A

the process of combining & establishing dependencies between beans

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is auto-wiring?

A

@Autowired

  • tells the container to enable dependency injection
  • declare all bean dependencies
  • container can auto-wire relationships between beans
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The default scope of a bean is “singleton” (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the Stereotype annotations in Spring?

A

@Component:
@Service:
@Repository:
@Controller: front controllers and responsible to handle user requests and return the appropriate response

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the @Configuration do?

A

indicates that a class has one or more @Bean methods to be processed by the Spring container to generate bean definitions and service requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does @component do?

A

allows Spring to detect our beans by marking the beans as Spring’s managed components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does @Repository do?

A

indicates a class as a repository

- able to store data
- retrieving & search data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does @Service do?

A

used with classes that provide some business functionalities

17
Q

what does @Controller do?

A
  • marks a class as a web request handler
  • allows for use of mapping annotations
    - ie: @RequestMapping