title: Spring Bean Autowiring error
body: <p>I am trying to implement email functionality in my app but I keep getting </p>
  
  <pre><code>No matching bean of type [org.springframework.mail.javamail.JavaMailSenderImpl] found for dependency:  expected at least 1 bean which qualifies as autowire candidate for this dependency.
  </code></pre>
  
  <p>Can anyone point out what I am doing incorrectly? </p>
  
  <p>The xml config for the bean is:</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:context="http://www.springframework.org/schema/context"   
  xsi:schemaLocation="
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
  &lt;annotation-driven /&gt;
  &lt;context:annotation-config/&gt;
  //...other stuff
  
  &lt;beans:bean id="mailSession" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;beans:property name="jndiName" value="EmailServer" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="emailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
      &lt;beans:property name="session" ref="mailSession"/&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>EmailServiceImpl class:</p>
  
  <pre><code>@Service
  public class EmailServiceImpl implements EmailService {
  
      @Autowired
      private JavaMailSenderImpl emailSender; 
  
      //more code..
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BXbe4.png" alt="project_structure"></p>