title: Cannot get spring email to work
body: <p>I am trying to implement a spring email service for which I implemented the GOOF design pattern. I created an interface Email service as follows.</p>
  
  <p>public interface EmailService {</p>
  
  <pre><code>public void sendFeedbackEmail(FeedbackPojo feedbackPojo);
  
  public void sendGenericEmailMessage(SimpleMailMessage message);
  </code></pre>
  
  <p>}</p>
  
  <p>Then I created an abstract class which extends this interface and implements one of it's overridden methods which is <code>sendFeedbackEmail(FeedBackPojo feedbackpojo)</code> The implementation of this abstract class is as follows.</p>
  
  <pre><code>public abstract class AbstractEmailService implements EmailService {
  
  @Value("@{default.to.address}")
  private String defaultToAddress ;
  
  protected SimpleMailMessage preparedSimpleMailMessageFromFeedbackPojo(FeedbackPojo feedback){
      SimpleMailMessage message = new SimpleMailMessage();
      message.setTo(defaultToAddress);
      message.setFrom(feedback.getEmail());
      message.setSubject("[Subscriber]: Feedback Received from"+ feedback.getFirstName()+" "+feedback.getLastName()+"!");
      message.setText(feedback.getFeedback());
  
      return message;
  }
  
  @Override
  public void sendFeedbackEmail(FeedbackPojo feedbackPojo) {
      sendGenericEmailMessage(preparedSimpleMailMessageFromFeedbackPojo(feedbackPojo));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Then I created a class MockEmailService with the implementation of second method of the EmailService interface which is sendGenericEmail(SimpleMailMessage message) as follows</p>
  
  <p>public class MockEmailService extends AbstractEmailService{</p>
  
  <pre><code>private static final Logger log = 
  LoggerFactory.getLogger(MockEmailService.class);
  
  @Override
  public void sendGenericEmailMessage(SimpleMailMessage message) {
      System.out.println(message.toString());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Then I am creating an Autowired object of emailService in my controller class and simulating my emailservice as follows</p>
  
  <pre><code>@Controller
  </code></pre>
  
  <p>public class ContactController {</p>
  
  <pre><code>private static final org.slf4j.Logger log = LoggerFactory.getLogger(ContactController.class);
  public static final String FEEDBACK_MODEL_KEY="feedback";
  private static final String CONTACT_US_VIEW_NAME="contact/contact";
  
  @Autowired
  private EmailService emailService;
  
  
  @RequestMapping(value = "/contact",method = RequestMethod.GET)
  public String getContact(ModelMap model){
      FeedbackPojo feedbackPojo = new FeedbackPojo();
      model.addAttribute(ContactController.FEEDBACK_MODEL_KEY,feedbackPojo);
      return ContactController.CONTACT_US_VIEW_NAME;
  }
  
  @RequestMapping(value = "/contact",method = RequestMethod.POST)
  public String postContact(@ModelAttribute(FEEDBACK_MODEL_KEY) FeedbackPojo feedback){
      log.debug("Feedback content {}",feedback);
      emailService.sendFeedbackEmail(feedback);
      return ContactController.CONTACT_US_VIEW_NAME;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>However, when I try to run my application the application terminates and the error I receive is as follows</p>
  
  <p><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.subscriptionservice.backend.service.EmailService com.subscriptionservice.web.controllers.ContactController.emailService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.subscriptionservice.backend.service.EmailService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></p>
  
  <p>Can someone please point out the issue in my implementation. Thanks. </p>