title: Spring - Set properties on beans imported from a different context file
body: <p>Suppose that in your spring context file you have imported some context files that you cannot modify.</p>
  
  <p>Is there a way to set the properties of the beans imported ?
  I do not want to copy and paste the bean definition from the imported context files and modify it because this would create a wrong dependency between my code and the external library. </p>
  
  <p>I just need to modify one property of an existing bean.</p>
  
  <p>It should be possible in theory given that I can do it using a custom class that receives the bean to update as a dependency and modify its properties in the init-method.</p>
  
  <p>I am wondering if there is a standard syntax in Spring to do it.</p>
  
  <p>For example in library-context.xml there is the following bean definition:</p>
  
  <pre><code>&lt;bean id="the.message" class="com.someco.SomeClass"&gt;
    &lt;property name="message" value="default message" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I import this as an external dependency and so I do not have the option to modify this definition.</p>
  
  <p>Of course I can copy and paste this definition in my context and override it. This would be ok with a bean like the one in the example that is very simple. 
  The problem is that often the dependencies are much more complex and they can change in a different version of the library.</p>
  
  <p>What I want is to set a property of the bean "the.message" ignoring all the other details.</p>
  
  <p>I am thinking to use something like:</p>
  
  <pre><code>&lt;bean id="myproxy" class="com.myapp.Proxy" init-method="copyProperties"&gt;
      &lt;property name="proxied" value="the.message" /&gt;
      &lt;property name="message" value="my message" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This "proxy" is only used to set the properties of "the.message".</p>