1/29
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
does spring boot act as a queue or a stack?
stack, last in first out for tasks
What is the order for component data flow?
browser → controller → service → repository → database → then reverse to get back to browser
what does the browser do?
sends HTTP request and displays the HTML
what does the controller do?
handles requests (Spring MVC) (@GetMapping @PostMapping(“\…”)
What does service do?
handles business logic
What does repository do?
gives data access (Spring Data JPA)
what does database do?
stores tasks (H2)
what does view do?
template rendering HTML (thymeleaf)
what does @SpringBootApplication do?
turns on autoconfiguration, starts component scanning for beans, boots embedded server (default is port 8080)
what 2 annotations are needed to generate a random ID?
@ID @GeneratedValue(strategy = GenerationType.IDENTITY)
what is a bean?
an object created and managed by Spring
what are 5 common annotations to create beans in the IoC container?
@Component, @Service, @Repository, @Controller, @RestController
what does @Component annotation do
annotation indicating a bean that represents a generic spring managed class
what does @Service annotation do
annotation indicating a bean that represents business logic
what does @Repository annotation do?
annotation indicating a bean that represents a data access layer
What does @Controller annotation do?
annotation indicating a bean that represents MVC controller and returns views
What does @RestController annotation do?
annotation indicating a bean that returns JSON
How is dependency injection applied?
no new keyword is used and the dependency is listed in the constructor parameters. The class should be labeled as @Service or @Controller. Spring framework then handles the rest
What is IoC/ Inversion of Control?
spring framework control object creation and decides how to build the dependencies we list in the constructors
What is TodoController dependent on?
___ is dependent on TodoService
What is TodoService dependent on?
___ is dependent on TodoRepository
What is the flow within MVC?
browser←→ controller ←→ model ←→ view
what does model do in MVC?
manages data and rules (ex: Todo)
what does view do in MVC?
(thymeleaf) : controllers, services, repositories, configuration classes
what does controller do in MVC?
has methods handling HTTP requests and chooses which view and model to send back to the browser
how would you give code to show if there is an error in the model and what would control it?
th:if=”${error}” controlled in the model
how would you give code to print an error message and where would it be controlled?
th:text= “${error}” controlled in view
What do GETs do?
they show form and list
What do POSTs do?
they handle submissions
where does the main user interaction with spring boot occur?
with GET and POST