Some related issues of lombok.jar use, in order to use @Slf4j annotation in eclipse,

@Slf4j
This annotation comes from lombok, lombok can reduce a lot of template code


1. In order to use the @Slf4j annotation in eclipse, you can use the log variable directly in the project

Steps:
1) First, eclipse needs to install lombok.jar
2) Copy the downloaded lombok.jar to the eclipse installation directory, which is the same level as eclipse.ini,
3) Modify the eclipse.ini file and add two sentences of configuration File

-Xbootclasspath/lombok.jar
-javaagent:/usr/local/eclipse/lombok.jar

4) Restart eclipse,
5) Then select the project--->Right click--->bulid project; //That is to recompile the code
Note: 1) If it still doesn't work, it may be because the eclipse version is too high and the lombok.jar version is at the bottom. At this time, you can download the latest version of lombok.jar.

    2) Eclipse official command to install lombok.jar java -jar lombok.jar



Some other notes:

@NonNull : Annotated on the parameter, if the parameter of the class is null, an exception will be reported, throw new NullPointException (parameter name)
@Data : Annotated on the class, providing read and write properties for the class, and also provides equals() , hashCode(), toString() methods
@Log4j : Annotated on the class, provides a log object with a log4j attribute named log for the class
@Slf4j : Annotated on the class, provides the class with a log4j log with an attribute named log Object
@Cleanup : Note that before the variable is referenced, the resource is automatically reclaimed and the close() method is called by default.
@NoArgsConstructor: A parameterless constructor is automatically generated.
@AllArgsConstructor: Automatically generate an all-argument constructor.
@Builder : Annotated on the class to provide an internal Builder for the class

eg:

  @Cleanup InputStream in = new FileInputStream(args[0]);
  @Cleanup OutputStream out = new FileOutputStream(args[1]);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326381458&siteId=291194637