title: import bean resources based on spring profiles
body: <p>Below is the code for servlet-context.xml in my spring project. I want to import demo.xml file in case the profile is prod and demo-test.xml if the profile is test.</p>
  
  <pre><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:beans="http://www.springframework.org/schema/beans"
               xmlns:task="http://www.springframework.org/schema/task"
               xmlns:context="http://www.springframework.org/schema/context"
               xsi:schemaLocation="
                  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
                  http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
                  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
      &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
      &lt;annotation-driven /&gt;
  
      &lt;beans profile="test"&gt;
          &lt;import resource="demo-test.xml"&gt;&lt;/import&gt;
      &lt;/beans&gt;
      &lt;beans profile="prod"&gt;
          &lt;import resource="demo.xml"&gt;&lt;/import&gt;
      &lt;/beans&gt;
  
  
      &lt;task:annotation-driven
              executor="defaultExecutor"/&gt;
      &lt;!-- add an exception handler here. --&gt;
  
      &lt;task:executor id="defaultExecutor"
                     pool-size="50-200"
                     queue-capacity="1200"
                     keep-alive="10"
                     rejection-policy="CALLER_RUNS"/&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>But I am getting error <code>The matching wildcard is strict, but no declaration can be found for element 'beans'.</code> for line <code>&lt;beans profile="test"&gt;</code> and <code>'resource' attribute should be defined</code> for <code>&lt;import resource="demo-test.xml"&gt;&lt;/import&gt;</code></p>
  
  <p>Based on <a href="https://stackoverflow.com/questions/23830630/error-in-spring-xml-config-relating-to-bean-profiles">error in spring xml config relating to bean profiles</a> I even tried changing context to "<a href="http://www.springframework.org/schema/beans/spring-beans-3.2.xsd" rel="nofollow noreferrer">http://www.springframework.org/schema/beans/spring-beans-3.2.xsd</a>" but no luck. Can some one help me understand what does this error mean and how can I fix this?</p>