idea lombok
Introduction of lombok
Lombok is a Java library that automatically switches on editors and build tools. For simple Java objects, you can substitute getters and Setter methods in code with annotations such as @setter @getter. Lombok uses annotations, but instead of using reflection, it dynamically replaces annotations with concrete code at compile time. So the actual code that the JVM runs is the same as the classes that we write manually that contain the various tool methods.
Lombok annotations
Val: final declares a variable in fianl just like a dynamic language does. Var: with JDK10 @ Data: annotation on the class, will provide all of the attributes of the class to add the get and set methods, and add, equals, canEquals @ Setter, hashCode, and toString method: annotation on the class, add a set method for all attribute, comments on the property for the attribute set method @ Getter: annotation on the class, add the get method to all of the properties, comments on the attribute of the attribute provides the get method @ NotNull: When used in the parameter, if pass the null values when the call, will be thrown null pointer exception @ Synchronized to method, can lock the specified object, if not specified, the default to create an object locking @ the Log function in the class, create a Log properties @ Builder: using the Builder pattern to create objects @ NoArgsConstructor: create a a no-parameter constructor @ AllArgsConstructor: create a full constructor @ ToString refs: Create a ToString method @accessors (chain = true) that uses the chain setting property. The set method returns this object. @RequiredArgConstructor (StaticName = “of”) creates and generates a static method @UtilityClass: Utility class @ExtensionMethod: Sets parent class @FieldDefaults: Sets the scope of properties, such as private, public, etc., and can also set whether properties are final modified. @cleanup: Close streams, join points. @equalSandHashCode: Overrides the equals and hashCode methods. @toString: Create the toString method. @cleanup: Can be used for streams etc without needing to close the use of stream objects.
Lombok error resolution:
1. Use compiler to select javac
2. Enable Annotation Processing
. After installation, restart IDEA. Gives effect to the plugin
4. Maven versions do not agree with the idea lombok version
4. Idea2018 version
IntelliJ idea 2018.1.5 \ plugins \ android \ lib \ templates \ gradle \ wrapper \ gradle \ wrapper
idea under the install directory
ideaVersion=2018.1
start idea then manually install Lombok plugins and restart again
Read More:
- Error reporting when Lombok @ data and @ builder are used together
- Using Lombok to compile and report errors
- Spring integrates JUnit configuration
- Encapsulation of adding, deleting and modifying database by JDBC
- Realization of springboot authorization verification technology based on JWT
- Error in idea @ data entity class get / set
- Idea startup project Lombok error, no symbol found
- [idea] error occurred when using @ data annotation in Lombok: no related get / set method was found
- Common errors and modification methods of findbug
- How to handle exception in springboot
- Solution of idea using @ Autowired annotation to report errors
- ajax error 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- @Solution to get / set error in eclipse after using data annotation
- @In slf4j log.info Compile error: cannot find symbol log
- Springboot error: property ‘sqlsessionfactory’ or ‘sqlsessiontemplate’ are required error details
- Elasticsearch in Spring uses Spel to dynamically create Index of Documet class
- Pit encountered by entity class data type BigDecimal
- Spring MVC 406 status code / could not find acceptable representation
- How to Use the object of ES6 to clear the object value
- Override the equals method and override the toString method