Above, Spring Boot extracted the step of declaring logs and made it into a reusable class. We wrote a public class for creating logs, but naturally someone will write it well for such a simple thing.
lombok has provided this tool
First we need to add this piece of code to pom.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
Bring lombok in
, then find the class that you want to use the log before, remove the inherited code, we no longer need to write it ourselves,
and add an annotation at the top.
@Slf4j
Then we can use the log normally in this class. The attribute name is also called log.
Then we start the project again
. Then we access the interface.
Then we look back at the editor. We
can see that there is no problem. After all, this is just a small function.