[JAVA] Annotations used in Spring Boot task management tool

Overview

I'm doing a course to make a task management tool using Udemy's React and Spring Boot, and I didn't understand the annotations at all, so I will summarize the annotations I used.

Annotations used

Controller.java

Annotation meaning
@RestController Used when creating a class that is the entry point of WebAPI
@RequestMapping Map paths and HTTP methods
@CrossOrigin Allow access in CORS settings
@PostMappting Annotations for POST requests
@GetMapping Annotation for GET request
@DeleteMapping Annotation for DELETE request
@PatchMapping Annotations for PATCH requests

Service.java

Annotation meaning
@Service Managed by Spring Boot container when the app starts
@Autowired Inject bean

Repository.java

Annotation meaning
@Repository Managed by Spring Boot container when the app starts
@Override Be sure to override the method

Exception.java

Annotation meaning
@ControllerAdvice Special method dedicated to Controller(@Exception handler etc.)To@RestControllerTo付与したクラスで共有できる
@RestController Recognized as Controller
@ExceptionHandler You can make settings for exceptions that occur in the Controller class.
@ResponseStatus Set HTTP status code

Domain.java

Annotation meaning
@Entity Defined to be a JPA entity
@Id @Adapt Generated Value
@GeneratedValue Generate primary key
@OneToOne You can create a one-to-one relationship. Cascade can also be specified
@OneToMany Have a one-to-many relationship. Cascade can also be specified
@ManytoOne You can create a many-to-one relationship. Cascade can also be specified
@JoinColumn Used when adding columns
@JsonIgnore Excludes Json output
@NotBlank Required. Null, empty string, space cannot be entered
@Size You can limit the number of characters
@Column Columns can be set
@JsonFormat You can convert it to the format you want to output and output it.
@PrePersist Specify the process to be executed before object persistence
@PreUpdate Specifies what to do before the object's attributes are updated

Recommended Posts

Annotations used in Spring Boot task management tool
Separate Task Executors used in Spring @Async
View the Gradle task in the Spring Boot project
Set context-param in Spring Boot
Spring Boot tutorial task schedule
Spring Boot 2 multi-project in Gradle
Major changes in Spring Boot 1.5
Spring Boot application development in Eclipse
Write test code in Spring Boot
Frequent annotations for Spring Boot tests
Implement REST API in Spring Boot
What is @Autowired in Spring boot?
Thymeleaf usage notes in Spring Boot
Build Spring Boot + Docker image in Gradle
Static file access priority in Spring boot
How to include Spring Tool in Eclipse 4.6.3?
Output Spring Boot log in json format
Local file download memorandum in Spring Boot
Create Java Spring Boot project in IntelliJ
Loosen Thymeleaf syntax checking in Spring Boot
[Practice! ] Display Hello World in Spring Boot
Use DynamoDB query method in Spring Boot
DI SessionScope Bean in Spring Boot 2 Filter
Change session timeout time in Spring Boot
SameSite cookie in Spring Boot (Spring Web MVC + Tomcat)
Run a Spring Boot project in VS Code
Output request and response log in Spring Boot
Use Servlet filter in Spring Boot [Spring Boot 1.x, 2.x compatible]
How to add a classpath in Spring Boot
Java tips-Create a Spring Boot project in Gradle
How to bind to property file in Spring Boot
Challenge Spring Boot
Spring Boot Form
Spring Boot Memorandum
gae + spring boot
Specify the encoding of static resources in Spring Boot
Include external jar in package with Spring boot2 + Maven3
I checked asynchronous execution of queries in Spring Boot 1.5.9
How to create a Spring Boot project in IntelliJ
SSO with GitHub OAuth in Spring Boot 1.5.x environment
How to use CommandLineRunner in Spring Batch of Spring Boot
Test field-injected class in Spring boot test without using Spring container
Until you start development with Spring Boot in eclipse 1
Try gRPC in Spring Boot & Spring Cloud project (Mac OS)
Introduce swagger-ui to REST API implemented in Spring Boot
Until you start development with Spring Boot in eclipse 2
Specify spring.profiles.active via context-param of web.xml in Spring Boot
SerializationException in Spring Boot (1 series) + spring-security-oauth2 + Redis Session + Heroku
Database environment construction with Docker in Spring boot (IntellJ)