Copy POJO content from one bean to another

If you already have spring dependencies you could use org.springframework.beans.BeanUtils

BeanUtils.copyProperties(from, to);

Any reason why Apache BeanUtils.copyProperties does not work?


Well.. Dozer may be just the thing you're looking for.

. . . its an object to object mapping framework. The idea is that:

  • Usually it will map by convention.
  • You can override this convention with a mapping file.

. . therefore mapping files are as compact as possible. Its useful for many cases, such as mapping a use-case specify service payload on to the reusable core model objects.

When delivering the SpringSource training courses we used to point out this framework very often.


See to mapstruct. This tools generates code, so there is no overhead on reflection.