title: castors unmarshalling mapping internal classes from xml, spring-boot
body: <p>I have an xml file that i map to 2 java classes using castors unmarshalling. It currently looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configurations&gt;
      &lt;Port&gt;8007&lt;/Port&gt;
      &lt;EnableHttps&gt;true&lt;/EnableHttps&gt;
      &lt;KeyStorePath&gt;classpath:ssl-server.jks&lt;/KeyStorePath&gt;
      &lt;KeyPass&gt;changeit&lt;/KeyPass&gt;
      &lt;TokenTtlMillis&gt;15000&lt;/TokenTtlMillis&gt;
    &lt;Users&gt;
      &lt;Username&gt;user1&lt;/Username&gt;
      &lt;Password&gt;$2a$10$kIWaw2g1w0TC.RUtr1k3nu3PBZ9qtaLvAMhFmtbF2X8cwiXC9OXhS&lt;/Password&gt; &lt;!-- password --&gt;
    &lt;/Users&gt;
    &lt;Users&gt;
      &lt;Username&gt;user2&lt;/Username&gt;
      &lt;Password&gt;$2a$10$jxGxonindJQgZjQoRxDhPewFjOo0F3ZoU8.VOFEOHTuMIJHRVTyF6&lt;/Password&gt; &lt;!-- password2 --&gt;
    &lt;/Users&gt;
  &lt;/Configurations&gt;
  </code></pre>
  
  <p>Now i would like to wrap my <code>&lt;users&gt;</code>in another <code>&lt;users&gt;</code>so it looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configurations&gt;
    &lt;Port&gt;8007&lt;/Port&gt;
    &lt;EnableHttps&gt;true&lt;/EnableHttps&gt;
    &lt;KeyStorePath&gt;classpath:ssl-server.jks&lt;/KeyStorePath&gt;
    &lt;KeyPass&gt;changeit&lt;/KeyPass&gt;
    &lt;TokenTtlMillis&gt;15000&lt;/TokenTtlMillis&gt;
    &lt;Users&gt;
      &lt;User&gt;
        &lt;Username&gt;user1&lt;/Username&gt;
        &lt;Password&gt;$2a$10$kIWaw2g1w0TC.RUtr1k3nu3PBZ9qtaLvAMhFmtbF2X8cwiXC9OXhS&lt;/Password&gt; &lt;!-- password --&gt;
      &lt;/User&gt;
      &lt;User&gt;
        &lt;Username&gt;user2&lt;/Username&gt;
        &lt;Password&gt;$2a$10$jxGxonindJQgZjQoRxDhPewFjOo0F3ZoU8.VOFEOHTuMIJHRVTyF6&lt;/Password&gt; &lt;!-- password2 --&gt;
      &lt;/User&gt;
    &lt;/Users&gt;
  &lt;/Configurations&gt;
  </code></pre>
  
  <p>How do i do this in the mapping file? Currently looks like this, with 1 class having a list of the other class</p>
  
  <pre><code>&lt;mapping&gt;
    &lt;class name="com.cetrea.securityservice.bean.Configurations" auto-complete="true"&gt;
      &lt;map-to xml="Configurations"/&gt;
      &lt;field name="port" type="int"&gt;
        &lt;bind-xml name="Port" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="enableHttps" type="boolean"&gt;
        &lt;bind-xml name="EnableHttps" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="keyStorePath" type="string"&gt;
        &lt;bind-xml name="KeyStorePath" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="keyPass" type="string"&gt;
        &lt;bind-xml name="KeyPass" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="TTL" type="int"&gt;
        &lt;bind-xml name="TokenTtlMillis" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="Users" collection="arraylist" type="com.cetrea.securityservice.bean.Users"&gt;
        &lt;bind-xml name="Users"/&gt;
      &lt;/field&gt;
    &lt;/class&gt;
    &lt;class name="com.cetrea.securityservice.bean.Users" auto-complete="true"&gt;
      &lt;map-to xml="Users"/&gt;
      &lt;field name="Username" type="string"&gt;
        &lt;bind-xml name="Username" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="Password" type="string"&gt;
        &lt;bind-xml name="Password" node="element"/&gt;
      &lt;/field&gt;
    &lt;/class&gt;
  &lt;/mapping&gt;
  </code></pre>
  
  <p>I'm thinking i need the Configurations class, to have a field that is the Users class, and then the Users class needs to have a list of users. But i cant really wrap my head around how to implement it, and what to change in my java model classes</p>