title: Copy properties from one bean to another (not the same class) recursively (including nested beans)
body: <p>Which approach requires the least amount of own written code to achieve a deep copy of one bean to another? The goal is to do it in an automatic way when source and target properties are matched by name.</p>
  
  <p>source main bean:</p>
  
  <pre><code>public class SourceBean {
      private String beanField;
      private SourceNestedBean nestedBean;
  
      // getters and setters
  }
  </code></pre>
  
  <p>source nested bean:</p>
  
  <pre><code>public class SourceNestedBean {
      private String nestedBeanField;
  
      // getters and setters
  }
  </code></pre>
  
  <p>target main bean:</p>
  
  <pre><code>public class TargetBean {
      private String beanField;
      private TargetNestedBean nestedBean;
  
      // getters and setters        
  }
  </code></pre>
  
  <p>target nested bean:</p>
  
  <pre><code>public class TargetNestedBean {
      private String nestedBeanField;
  
      // getters and setters
  }
  </code></pre>
  
  <p><br></p>
  
  <p>Using e.g. <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/BeanUtils.html#copyProperties-java.lang.Object-java.lang.Object-" rel="noreferrer">Spring BeanUtils.copyProperites()</a> I could create a shallow copy of a <code>SourceBean</code> to <code>TargetBean</code> with one line of code but it will not copy nested beans. Is there any mature utility (not necessarily Spring Framework) that would allow to do the deep copy while <strong>writing as least own code as possible</strong> (pretty much same as BeanUtils.copyProperties())? </p>