Annotations Flashcards
(4 stereotype annotations:)
- General/generic annotation to make a Spring bean
@Component
(4 stereotype annotations:)
- DAO Classes that you want to make a Spring bean
@Repository
(4 stereotype annotations:)
- Service Classes that you want to make Spring Bean
@Service
(4 stereotype annotations:)
- Controller Classes that you want to make a Spring
@Controller
will abstract away the dependency injection that it does for you. So to us, it looks automatic and magical.
@Autowired
used To run a Spring Boot application
@SpringBootApplication
(spring MVC)
Preferred stereotype annotation for MVC Controllers. Makes the Class a bean, as well as allowing the class to use the annotations below and get noticed by the DispatcherServlet
@Controller
(Spring MVC)
- Specifies the path URI (endpoint) that will be delegated to this controller class or method. We also use it to specify particular HTTP verbs.
@GetMapping
@PostMapping
Etc.
@RequestMapping
(Spring MVC)
- sets up Cors filtering for us (so that we can get requests from the front end and send back responses)
@CrossOrigin
(Spring MVC)
- Converts the body of our response to JSON for us. Placed at either the class level or method level. No more GSON!
@ResponseBody
(Spring MVC)
- allows for getting a path variable out of a URI and used in the parameter of the controller method that took the request.
@PathVariable
(Spring MVC)
- Parses the JSON body of the request to an object specified in the parameters of the Controller method that took the requests
@RequestBody
(Spring MVC)
- This combines the two annotations of @Controller and @ResponseBody. Convenient!!!
@RestController
(JPA Annotations)
- Indicates that the Class is meant to be mapped to a DB table
@Entity
(JPA Annotations)
- Doesn’t actually make a class a table (@Entity does that) but it’s useful for setting table options such as the name of the table in the database
@Table