title: Conditionally load a bean in spring boot using xml configuration?
body: <p>I am using Spring Boot 2.1.</p>
  
  <p>I have some mixed configuration in my project : XML files and java classes with annotations.
  We have this current configuration which works :</p>
  
  <p>application.properties :</p>
  
  <pre><code>spring.profiles.active=dev, component1, component2
  </code></pre>
  
  <p>applicationContext-file.xml  :</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd"
    profile="component1"&gt; 
      &lt;beans&gt;
          &lt;bean id="myserviceimpl"
              class="org.blabla.MyServiceImpl"&gt;
              &lt;property name="mydao"&gt;
                  &lt;ref bean="mydao"&gt;&lt;/ref&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/beans&gt;
  &lt;/beans&gt;   
  </code></pre>
  
  <p>We want to extract the component values from the spring.profiles.active property since they have nothing to do with the environment :</p>
  
  <p>application.properties :</p>
  
  <pre><code>spring.profiles.active=dev
  component1=true
  component2=true
  </code></pre>
  
  <p>How can i condition the instantiation of the myserviceimpl bean inside the applicationContext-file.xml ?
  I can no longer rely on the profile attribute since the spring.profiles.active property no longer includes
  the values of the components.</p>
  
  <p>Thanks for helping.</p>