Lombok causes BeanUtils method to fail

Lombok is used in the project, and the java bean looks more concise, without a lot of getters and setters, and equals, construction methods, toString, etc. are automatically added, but a fatal problem is that the setProperty and copyProperties methods in the apache common-beanutils package are invalid, and the beanutils in the springframework package is ok. It is still reliable to manually complete the getter and setter.

 

So, to summarize Lombok based on the current experience, maybe it is wrong:

advantage:

  1. The code is concise, and there are few getters and setters that don't make much sense. (However, to generate these methods in eclipse is just a matter of pressing the shortcut key, not even 3 seconds)
  2. Save trouble, if you write these methods of toString by yourself, it will take some time

shortcoming:

  1. Force others to use. If you use this plug-in, then everyone must use it, otherwise it won’t compile on other people’s machines.
  2. I don't know where the hole is. At least currently common-beanutils-1.9.3 will have problems.

If you just want to use toString and construction methods, you can add corresponding annotations to the java bean separately, "@ToString", "@AllArgsConstructor", "@RequiredArgsConstructor", etc.,

Guess you like

Origin blog.csdn.net/bokix/article/details/100134787