SB-NG Flashcards
Auto-configuration
When configuring your Spring Boot application, it downloads all the dependencies needed to run your application
Opinionated approach
Spring Boot uses a narrow approach to installing dependencies based on your application’s needs. Manual configuration is removed as it adds the packages you need for your application.
Spring starters:
We can choose a list of starter dependencies to define your application’s expected needs during the initialization process. One example is Spring Web, which allows us to initialize a Spring-based web application.
SB: Presentation/display layer
The presentation layer is responsible for interpreting JSON parameters as objects. This layer is the upper layer that is also responsible for handling authentication and HTTP requests. After accomplishing JSON translation and authentication, we will now move to the business layer.
SB: Business layer:
The business layer, as the name suggests, handles all the business logic in the application. It is composed of service classes that perform authorization and additional validation.
Persistence layer
The persistence layer is mainly responsible for storage logic that converts objects from and to database rows to insert data.
Database layer
The database layer performs Create, Read, Update, and Delete (CRUD) operations. The layer can consist of multiple databases.
Inversion of Control (IoC)
the concept of inverting the flow of your program, and it is used for decoupling the components in your application, making your piece of code reusable and modular
Constructor-based dependency injection
can be achieved by creating an object class with a constructor, with arguments of a specific type representing the dependency we can set.
Beans.xml
main configuration file for our construction-based injection, which is where we will define our beans together with their dependencies.
Spring: @Configuration
used to mark a class as a source of bean definitions
Spring: @ComponentScan
makes Spring scan the packages configured with it for the @Configuration classes
Spring: @Import
loads additional configuration. Works even when you specify beans in XML file
Spring: @Component
turns the class into a Spring bean at the auto-scan time
Spring: @Service
tells Spring that it’s safe to manage @Components with more freedom than regular components
Spring: @Autowired
wires the application parts together, on the fields, constructors, or methods in a component
mainly used to inject dependencies without the use of constructors and setter methods
Spring: @Bean
specifies a returned bean to be managed by Spring context. Returned bean has same name as factory method
@SpringBootApplication
uses @Configuration, @EnableAutoConfiguration and @ComponentScan
SB: @EnableAutoConfiguration
make Spring guess the configuration based on the classpath
SB: @Controller
marks the class as web controller, capable of handling the requests