title: Spring: how to hide bean from dependency injection?
body: <p>The situation is that I have two different resource bundles, a general one and a more specific one. They don't share any message keys.</p>
  
  <p>General one:</p>
  
  <pre><code>&lt;bean id="messageSourceGlobal" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
      &lt;property name="basename" value="messages/messagesGlobal" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I include the general one in my specific one (different file obviously):</p>
  
  <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
      &lt;property name="basename" value="messages/messages" /&gt;
      &lt;property name="parentMessageSource" ref="messageSourceGlobal" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The Java-code then autowires it:</p>
  
  <pre><code>@Autowired
  private MessageSource messages;
  </code></pre>
  
  <p>This will cause an exception when starting the web-app as two <code>MessageSource</code>s are found. Obviously I can use a <code>@Qualifier</code> to make it clear to Spring what I want. However, the general resource bundle won't be used alone. Therefore, I thought that in this case it would make sense to hide the general resource bundle from dependency injection. One benefit would be that others won't run into the "duplicates".</p>
  
  <p>Is this possible? How would I do this?</p>