title: applicationContext.xml file not being read in by Spring
body: <p>I've been reading a ton of examples in StackOverflow on the subject of ApplicationContextProvider, but I can't find a single one that addresses my problem.  I have an xml file that I don't believe is being read in and initializing the beans that I note in it.  I have the following class:</p>
  
  <pre><code>package com.tacticalenterprisesltd.spring;
  
  import org.springframework.beans.BeansException;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.ApplicationContextAware;
  import org.springframework.stereotype.Component;
  
  @Component
  public class ApplicationContextProvider implements ApplicationContextAware
  {
      @Autowired
      private static ApplicationContext context;
  
      public ApplicationContext getApplicationContext()
      {
          return context;
      }
  
      @Override
      public void setApplicationContext(ApplicationContext ac) throws BeansException {
          System.out.println("ApplicationContext Initialized");
          context = ac;
      }       
  }
  </code></pre>
  
  <p>My applicationContext.xml file:</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:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd"&gt;
  
      &lt;mvc:annotation-driven /&gt;
      &lt;tx:annotation-driven /&gt;
      &lt;context:component-scan base-package="com.tacticalenterprisesltd" /&gt;
      &lt;bean id="applicationContextProvider" class="com.tacticalenterprisesltd.spring.ApplicationContextProvider" /&gt;
      &lt;bean id="springDatabase" class="com.tacticalenterprisesltd.spring.SpringDatabase" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>JedSpringTestApplication:</p>
  
  <pre><code>package com.tacticalenterprisesltd.jedspringtest;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  @ComponentScan(basePackages = {"com.tacticalenterprisesltd"})
  public class JedSpringTestApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(JedSpringTestApplication.class, args);
  
      }
  }
  </code></pre>
  
  <p>and finally, PersonelSearch class:</p>
  
  <pre><code>package com.tacticalenterprisesltd.jedspringtest;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  
  import com.tacticalenterprisesltd.Field;
  import com.tacticalenterprisesltd.Query;
  import com.tacticalenterprisesltd.WhereCondition;
  import com.tacticalenterprisesltd.spring.ApplicationContextProvider;
  import com.tacticalenterprisesltd.spring.SpringDatabase;
  
  @Controller
  public class PersonnelSearch 
  {
      @Autowired
      ApplicationContextProvider applicationContextProvider ;
  
      @RequestMapping("/search")
      public String search(@RequestParam(value="lastname", required=true) String lastname, Model model) {
          model.addAttribute("lastname", lastname);
          SpringDatabase sd = (SpringDatabase)applicationContextProvider .getApplicationContext().getBean("springDatabase", com.tacticalenterprisesltd.spring.SpringDatabase.class);
          Query query = new Query(Query.Type.SELECT, "employees");
          Field field1 = new Field("employees", "id", Field.Type.INT);
          Field field2 = new Field("employees", "first_name", Field.Type.STRING);
          Field field3 = new Field("employees", "last_name", Field.Type.INT);
          Field field4 = new Field("employees", "email", Field.Type.INT);
          Field[] fields = new Field[4];
          fields[0] = field1;
          fields[1] = field2;
          fields[2] = field3;
          fields[3] = field4;
          query.setFields(fields);
          WhereCondition where = new WhereCondition(field3, lastname, "=");
          WhereCondition[] conditions = new WhereCondition[1];
          conditions[0] = where;
          query.setWhereConditions(conditions);
          sd.setQuery(query);
          String[][] strData = sd.executeSelect();
          String out = "";
          for(int i = 0; i &lt; strData.length; i++)
          {
              out += " | ";
              for(int j = 0; j &lt; strData[0].length; j++)
              {
                  out += strData[i][j] + " | ";
              }
              out += "\n";
          }
          System.out.println("Table Results:\n" + out);
          return out;
      }
  }
  </code></pre>
  
  <p>When I run this as a Spring Boot application I get:</p>
  
  <pre><code>Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personnelSearch': Unsatisfied dependency expressed through field 'applicationContextProvider'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tacticalenterprisesltd.spring.ApplicationContextProvider' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
      Description:
  
  Field applicationContextProvider in com.tacticalenterprisesltd.jedspringtest.PersonnelSearch required a bean of type 'com.tacticalenterprisesltd.spring.ApplicationContextProvider' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'com.tacticalenterprisesltd.spring.ApplicationContextProvider' in your configuration.
  </code></pre>
  
  <p>I'm thinking that the applicationContext.xml file is not being read in, otherwise the beans that are noted inside it would be available when the application loads.  Please advise.</p>