JEE - Spring - Spring Boot 3 Flashcards
What is Spring ?
Spring is a Java Framework. Its core feature is IoC and DI.
______________________________________________
IoC=>Spring manages objects in Java instead of Programmer
DI=>manages objects dependencies allowing objects to be loosely coupled
What is IoC ?
IoC is a principle that consist on delegating reponsibility of creating and managing an object to an external container or framework ( ex : Spring’s IoC Container )
What is Dependency Injection (DI)?
DI is a specific design pattern used on implementing IoC , which consist on injectiong required dependencies on object instead of the object creating them itself.
this is done at runtime , either through constructor injection , setter injection or field injection ( annotation @Autowired )
What is difference between IoC and DI ?
DI is a specific design pattern used on implementing IoC
What is Beans in Spring ?
Bean is a java object, they can be created using xml configuartion ( in applicationContext.xml ) , annotations or java-based configuration.
What are Types of Beans / scopes ?
*Singleton Bean : By default , Spring beans are Singleton , meaning only one instance of bean is created per Spring container. Every time you request a bean from the container , the same instance is returned.
*Prototype Bean : A prototype beans mean a new instance is created every time it is requested.
*Other scopes : request , session , global-session in web applications
Beans Lifecycle management ?
Initializing and destruction of beans is managed by annotations @PostConstruct and @PreDestroy
Bean names ?
Each bean can be identified by a unique name defined in Spring Container
What is Context in Spring ?
It refers to Spring ApplicationContext which servers as main interface to access beans in Spring Container ( it is a more advanced version of BeanFactory )
It is where the Spring Container is initialized and it is responsible for managing complete lifecycle of beans.
Example of bean definition in xml configuration file :
<bean>
<property></property>
</bean>
What is Spring Boot ?
Spring Boot is an extension of Spring Framework that simplify development of Spring applications by reducing configuration complexity and speeding up development.
What is difference between Spring and Spring Boot ?
Spring Boot provides auto-configuration , embedded servers, and production-ready features for quick development ( especially microservices ), while Spring provides more flexibility and customization but requires more manual configurations and setups.
=> Use Spring Boot for quick standalone apps , and Spring to have a full control over application configuartions.
What are Common annotations of Spring Boot ?
view word doc
Other resource for interview JAVA/JEE :
https://github.com/ouhamzalhss