title: Spring @Value property is null inside of custom pojo
body: <p>I created a simple JavaMailSender spring-boot application (just for fun). Here is a reference to the code on GitHub:</p>
  
  <p><a href="https://github.com/carlcorder/mail.sender" rel="nofollow noreferrer">https://github.com/carlcorder/mail.sender</a></p>
  
  <p>I am having a problem where inside the Email class, the "from" property is null even though I annotate it with @Value (aside from that, everything works perfectly). The class is as follows:</p>
  
  <pre><code>package com.mail.sender.domain;
  
  import lombok.NonNull;
  import org.springframework.beans.factory.annotation.Value;
  
  @lombok.Data
  @lombok.AllArgsConstructor
  @lombok.NoArgsConstructor
  @lombok.Builder
  public class Email {
  
      @NonNull
      private String to;
  
      @NonNull
      //@Value("{spring.mail.username}") --&gt; this is always null
      private String from;
  
      @NonNull
      private String subject;
  
      private String body;
  
  }
  </code></pre>
  
  <p>I have read these posts and understand the problem is most likely related.</p>
  
  <p><a href="https://stackoverflow.com/questions/3652090/difference-between-applicationcontext-xml-and-spring-servlet-xml-in-spring-frame">Difference between applicationContext.xml and spring-servlet.xml in Spring Framework</a></p>
  
  <p>and this:</p>
  
  <p><a href="https://stackoverflow.com/questions/11890544/spring-value-annotation-in-controller-class-not-evaluating-to-value-inside-pro">Spring @Value annotation in @Controller class not evaluating to value inside properties file</a></p>
  
  <p>However I was still unable to get anything working. Any help would be greatly appreciated.</p>