Migrated
This commit is contained in:
39
Advanced Programming/Annotation Repository.md
Normal file
39
Advanced Programming/Annotation Repository.md
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
type: practical
|
||||
---
|
||||
|
||||
## Lombok
|
||||
### `@AllArgsConstructor`(onConstructor_=@Annotation)
|
||||
- Creates a public constructor which takes in all args
|
||||
- `onConstructor_`: Places an annotation on the constructor
|
||||
|
||||
### `@Data`
|
||||
A shortcut for `@ToString`, `@EqualsAndHashCode`, `@Getter` on all fields, and `@Setter` on all non-final fields
|
||||
|
||||
## Spring
|
||||
|
||||
### `RestController`
|
||||
Extends Controller. Used to declare a class as a REST controller
|
||||
### `@Autowired`
|
||||
- Annotates a constructor
|
||||
- Basically, it figures out dependency injection on its own
|
||||
|
||||
### `@[Get/Post/Put/Delete]Mapping("/path/")`
|
||||
Makes an endpoint at path.
|
||||
|
||||
### `@RequestParam`
|
||||
Describe the param and type
|
||||
|
||||
```java
|
||||
@GetMapping("/api/foos")
|
||||
@ResponseBody
|
||||
public String getFoos(@RequestParam String id) {
|
||||
return "ID: " + id;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Beans
|
||||
![[Beans.canvas|Beans]]
|
||||
|
Reference in New Issue
Block a user