Spring Flashcards

1
Q

A bean is a Singleton because…

A

Only one of them are created. We can call it several times, but only one new is created one time.
IT IS A GOOD THING :D

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

5 Scopes available to configure a bean

A

Singleton
Prototype
+ valid in only web-aware projects:
Request
Session
Global

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

Scope: Prototype and bean

A

A new bean per request.
You would rather have a singleton

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

Scope: Singleton and bean

A

Restricts the instantiation of a class to just one object.
Is the default bean scope inside of spring
= One instance per spring container or context

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

Scope: Request and bean (web)

A

Returns a bean per request. short lived bean

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

Scope: Session and bean (web)

A

Returns a bean per session. The bean lives as long as the session.

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

Scope: Global session and bean (web)

A

returns a bean per application. Once i access the bean, it’s alive as long as the application lives on the server

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

Stereotype Annotations

A

@Component (same thing as @Bean)
@Repository (Used to denote a class that is used as a repository object)
@Service (confusing, because service does not mean webservice or microservice. This is where you put your business logic)

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

Can “@Bean” be used at class level?

A

No, only on method level. If you wanna use it on Class level, use @Component

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

Session Locale resolver

A

Ties our session to a locale

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

What do you need to internationalize a Spring MVC app?

A

LocaleInterceptor

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

Where do you store your files to avoid deep linking?

A

src, main, java, WEB-INF

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

What piece of configuration is used to locate files and serve them to the UI?

A

ViewResolver

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

What annotation is used to accept an object in the parameters of a method in Controller?

A

@ModelAttribute

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

What are the four parts that make up Spring MVC Configuration?

A

pom.xml, Config, Java, View

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

What are the components of Spring?

A

Service, Repository, Controller

17
Q

What do RestControllers bypass and instead return a body?

A

ViewResolver

18
Q

What technique is used to help with form resubmission errors?

A

Post-Redirect-Get

19
Q

What does the most common Controller configuration return to locate the view?

A

A String representing the view name

20
Q

Spring recommends not serving up what view technology from self-contained JARs?

A

JSP pages