title: SPRING_APPLICATION_JSON environment variable not recognized by spring boot
body: <p>I'm new to spring boot and have an error so basic, I clearly have an obvious error. But I've RTM'ed and the docs and am missing a point:</p>
  
  <p><strong>tl/dr</strong></p>
  
  <p>how can I use  @Value annotation to get values from the "spring environment"?</p>
  
  <p><strong>Context</strong></p>
  
  <p>I seek to:</p>
  
  <ul>
  <li>pass 'jdbc info' (e.g., url/password/login) to the application/"spring environment" using environment variable SPRING_APPLICATION_JSON</li>
  <li>use this jdbc info in the application 'post process context' to set the url/creds/etc for jdbc jndi</li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <ul>
  <li>I have set environment variable SPRING_APPLICATION_JSON, but spring boot does not appear to "pick it up"</li>
  </ul>
  
  <p><strong>Example Calling program</strong></p>
  
  <p>Both of these fail:</p>
  
  <pre><code>SPRING_APPLICATION_JSON='{"spring": {"datasource": { "url":"jdbc:mysql://localhost:3306/myapp", "username":"myappuser", "password":"mypassword" } } }' java -jar build/libs/myapp_springboot.war  
  </code></pre>
  
  <p>and</p>
  
  <pre><code>-Dspring.application.json='{"spring": {"datasource": { "url":"jdbc:mysql://localhost:3306/myapp", "username":"myappuser", "password":"mypassword" } } }' java -jar build/libs/myapp_springboot.war  
  </code></pre>
  
  <p><strong>Example Usage</strong> </p>
  
  <p>Here's the class that  tries to access:</p>
  
  <pre><code>@Component
  public class DbInfo
  {  
     @Value("${spring.datasource.url}")
     String fUrl;
  </code></pre>
  
  <p>Note that I didn't have any "PropertySource stuff". I initially thought that I would get that for free.</p>
  
  <p><strong>Error</strong></p>
  
  <blockquote>
    <p>Could not resolve placeholder 'spring.datasource.url' in string value
    "${spring.datasource.url}"</p>
  </blockquote>
  
  <p><strong>Also Tried this</strong></p>
  
  <p>I have tried this:</p>
  
  <pre><code>@Configuration
  @PropertySource({
          "classpath:application.properties",
  })
  public class MyDbInfo
  {
  
     @Autowired
     Environment fEnvironment;
  </code></pre>
  
  <p><strong>Environment</strong></p>
  
  <pre><code>springBootVersion = '1.4.2.RELEASE'
  </code></pre>
  
  <p><strong>Reference</strong></p>
  
  <p><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-vs-value" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-vs-value</a></p>
  
  <p>Thanks in advance</p>