Spring Flashcards
A bean is a Singleton because…
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
5 Scopes available to configure a bean
Singleton
Prototype
+ valid in only web-aware projects:
Request
Session
Global
Scope: Prototype and bean
A new bean per request.
You would rather have a singleton
Scope: Singleton and bean
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
Scope: Request and bean (web)
Returns a bean per request. short lived bean
Scope: Session and bean (web)
Returns a bean per session. The bean lives as long as the session.
Scope: Global session and bean (web)
returns a bean per application. Once i access the bean, it’s alive as long as the application lives on the server
Stereotype Annotations
@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)
Can “@Bean” be used at class level?
No, only on method level. If you wanna use it on Class level, use @Component
Session Locale resolver
Ties our session to a locale
What do you need to internationalize a Spring MVC app?
LocaleInterceptor
Where do you store your files to avoid deep linking?
src, main, java, WEB-INF
What piece of configuration is used to locate files and serve them to the UI?
ViewResolver
What annotation is used to accept an object in the parameters of a method in Controller?
@ModelAttribute
What are the four parts that make up Spring MVC Configuration?
pom.xml, Config, Java, View