title: How do I externalize configuration with Spring Boot?
body: <p>It's just not working. I saw the docs at</p>
  <p><a href="https://docs.spring.io/spring-boot/docs/1.5.19.RELEASE/reference/htmlsingle/#boot-features-external-config" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/1.5.19.RELEASE/reference/htmlsingle/#boot-features-external-config</a></p>
  <p>I saw the answers at</p>
  <p><a href="https://stackoverflow.com/questions/39107413/spring-boot-externalize-config-properties-messages-on-java-annotations">Spring boot externalize config properties/messages on Java annotations</a></p>
  <p>I have</p>
  <pre><code>    MailTrainAPI mt = new MailTrainAPI();
      mt.sendMail(map);
  
  ...
  
  @Component
  public class MailTrainAPI {
      @Value(&quot;${mailtrain.url}&quot;)
      private String API;
  
      public void sendMail(MultiValueMap&lt;String, String&gt; map) {
          System.out.println(&quot;API = &quot;+API);
          API = System.getProperty(&quot;mailtrain.api&quot;);
          System.out.println(&quot;API = &quot;+API);
          API = System.getenv(&quot;mailtrain.api&quot;);
          System.out.println(&quot;API = &quot;+API);
  </code></pre>
  <hr />
  <code>src/main/resources/application.properties</code>
  <pre><code>mailtrain.url=http://mail.galaxy.store/api/send/galaxybadge
  </code></pre>
  <p>It prints</p>
  <pre><code>API = null
  API = null
  API = null
  </code></pre>
  <p>It doesn't work because I instantiate the class myself and Spring doesn't know about it. How do I access the property in the <code>application.properties</code> file manually?</p>
  <p>Spring Boot 1.5.21</p>