Spring boot not able to resolve OS environment variable?
<p>I deployed spring boot service to AWS and application.properties has refers to one of the OS environment variable which is being set as part of deployment process. It seems like Spring Boot fails to resolve the OS environment variable when booting up.</p>

<p>If I echo the variable it seems to be set correctly -</p>

<pre><code>ubuntu@ip-10-227-74-206:~$ echo $EC2_INSTANCE_ID
i-de8c136d
</code></pre>

<p>application.properties file refers to that variable as below -</p>

<pre><code>service.hostId=aws-${EC2_INSTANCE_ID}
</code></pre>

<p>I see below error when booting up the application -</p>

<pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.foo.services.registration.config; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'EC2_INSTANCE_ID' in string value "${EC2_INSTANCE_ID}"
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
</code></pre>

<p>Any idea what I could be doing wrong? Do I need to add any prefix like "sys:" when referring in application.properties file?</p>