It is for my own learning.
I started using Spring in my current project.
I don't understand the annotations that are characteristic of Java and Spring => Efficient implementation is not possible. Spring has not been used effectively.
The one in App.java @SpringBootApplication The class with this annotation indicates that it is a Spring Boot application class. There is a run method that boots Spring. It is used when you want to add various setting information at the time of execution.
@EnableScheduling Enable the schedule function. -> Allow use of @Scheduled
@Scheduled You can specify the execution time of the method. Periodic execution can be performed by taking the following arguments to the annotation. You can also use cron. Details ⇒ https://qiita.com/rubytomato@github/items/4f0c64eb9a24eaceaa6e
Lombok (the one that automatically creates getters and setters) related annotations There are three types. @NoArgsConstructor,@RequiredArgsConstructor, @AllArgsConstructor
These three are annotations that automatically generate a constructor when creating getters / setters with lombok.
@ </ span> NoArgsConstructor Generates a default constructor with no arguments. @ </ span> RequiredArgsConstructor creates a constructor with arguments to set values in fields with final. @ </ span> AllArgsConstructor Generates a constructor that takes initialization values for all fields as arguments
Behavior of RequiredArgsConstructor
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class Employee {
private final int id;
private String name;
}
Generated code
public class Employee {
private final int id;
private String name;
public Employee(final int id) {
this.id = id;
}
}
//Names without the final qualifier are not included in the constructor.
In ongoing PJ It is used in the form of @ </ span> RequiredArgsConstructor (onConstructor = @ </ span> __ ( @ </ span> Autowired)).
onConstructor = @ </ span> __ ( @ </ span> Autowired)) I wondered what (?), So I looked it up. According to the official Lambok documentation, it's placed to annotate the generated constructor (!?) https://projectlombok.org/features/constructor About onX-> OnConstructor, it was written as follows. "we heard you like annotations, so we put annotations in your annotations so you can annotate while you're annotating." "We heard that you like annotations, so I put them in your annotations, so you can annotate while you're annotating."
Recommended Posts