title: How to specify external YAML configuration file for springboot
body: <p>I'm trying to pass in a value to be autowired from a custom configuration file in Spring boot. Below are code snippets:</p>
  
  <p><strong><em>Spring class</em></strong></p>
  
  <pre><code>@Configuration
  public class MyConfig {
  
      @Value("${BOOTSTRAP_SERVERS}")
      private String bootstrapServers;
  </code></pre>
  
  <p><strong><em>myfile.yaml</em></strong></p>
  
  <pre><code>BOOTSTRAP_SERVERS: 
    10.0.0.12:9092
  </code></pre>
  
  <p><strong><em>Execution command</em></strong></p>
  
  <pre><code>java  -jar app.jar --spring.config.location=/file/path/myfile.yaml
  </code></pre>
  
  <p>However when I type the above command I'm getting this error:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Could not resolve placeholder 'BOOTSTRAP_SERVERS' in value "${BOOTSTRAP_SERVERS}"</p>
  </blockquote>
  
  <p>What am I missing here in order to get this to work? I intend to mount the app in kubernetes so I need to be able to externalize my configuration. Thanks in advance.</p>