title: Spring configure bean with properties
body: <p>I'm new in Spring, and want to figure out how to inject value from properties file.</p>
  <p>I have component with <code>Value</code> annotation:</p>
  <pre class="lang-java prettyprint-override"><code>@Component
  public class ConfigProp {
  
      private final String login;
  
      public ConfigProp(@Value(&quot;${login}&quot;) String login) {
          this.login = login;
      }
  
      @Override
      public String toString() {
          return &quot;ConfigProp{&quot; +
              &quot;login='&quot; + login + '\'' +
              '}';
      }
  }
  </code></pre>
  <p>then, I have main class:</p>
  <pre class="lang-java prettyprint-override"><code>public class App {
  
      public static void main(String[] args) {
          
          var context = new AnnotationConfigApplicationContext(ConfigProp.class);
          context.addBeanFactoryPostProcessor(new PropertySourcesPlaceholderConfigurer());
          
          var cp = context.getBean(ConfigProp.class);
          System.out.println(cp);
      }
  }
  </code></pre>
  <p>Additionally I have <code>application.properties</code> file
  with content:</p>
  <pre><code>login=some_login
  </code></pre>
  <p>And when I launching my app I'm getting <code>ConfigProp{login='${login}'}</code></p>
  <p>Yes, I know, I may annotate <code>ConfigProp</code> with <code>@PropertySource(path-to-properties)</code> annotation, but it's not a good solution, because in the Prod I may want to use another properties file,</p>
  <p>How can I resolve this issue?</p>