{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/3724","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/3724/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/3724/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/3724/events","html_url":"https://github.com/spring-projects/spring-boot/issues/3724","id":100303647,"number":3724,"title":"System environment variables not properly set in @ConfigurationProperties","user":{"login":"jvalkeal","id":50398,"avatar_url":"https://avatars.githubusercontent.com/u/50398?v=3","gravatar_id":"","url":"https://api.github.com/users/jvalkeal","html_url":"https://github.com/jvalkeal","followers_url":"https://api.github.com/users/jvalkeal/followers","following_url":"https://api.github.com/users/jvalkeal/following{/other_user}","gists_url":"https://api.github.com/users/jvalkeal/gists{/gist_id}","starred_url":"https://api.github.com/users/jvalkeal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvalkeal/subscriptions","organizations_url":"https://api.github.com/users/jvalkeal/orgs","repos_url":"https://api.github.com/users/jvalkeal/repos","events_url":"https://api.github.com/users/jvalkeal/events{/privacy}","received_events_url":"https://api.github.com/users/jvalkeal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-11T12:48:31Z","updated_at":"2015-08-11T13:36:53Z","closed_at":null,"body":"This is a new issue with boot 1.3.0.M3, works fine with 1.3.0.M2. This may not be a best method to use env variables but model below is used in both `XD` and `SHDP`. It's difficult to test env variables via unit tests so I'm using boot cli.\r\n\r\nAlso tests assumes that you set `SHDP_HD_FS` variable\r\n\r\n```\r\n$ export SHDP_HD_FS=myvar\r\n$ echo $SHDP_HD_FS\r\nmyvar\r\n```\r\n\r\nPay attention to log lines:\r\n```\r\nfs=myvar\r\n```\r\n\r\nand\r\n```\r\nfs=null\r\n```\r\n\r\nCode:\r\n```\r\n$ cat App1.groovy \r\npackage org.springframework.yarn.boot;\r\n\r\nimport org.springframework.context.annotation.Import;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.beans.factory.annotation.Value;\r\nimport org.springframework.boot.CommandLineRunner;\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\nimport org.springframework.boot.context.properties.ConfigurationProperties;\r\nimport org.springframework.boot.context.properties.EnableConfigurationProperties;\r\nimport org.springframework.yarn.boot.MyEnvProperties;\r\n\r\n@SpringBootApplication\r\n@EnableConfigurationProperties(MyEnvProperties.class)\r\npublic class App1 implements CommandLineRunner {\r\n\r\n\t@Autowired\r\n\tMyEnvProperties myEnvProperties;\r\n\r\n\t@Override\r\n\tpublic void run(String... args) throws Exception {\r\n\t\tSystem.out.println(\"fs=\" + myEnvProperties.getFs());\r\n\t}\r\n\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tSpringApplication.run(App1.class, args);\r\n\t}\r\n\r\n\r\n}\r\n\r\n@ConfigurationProperties\r\npublic class MyEnvProperties {\r\n\tprivate String fs;\r\n\tpublic void setSHDP_HD_FS(String fs) {\r\n\t\tthis.fs = fs;\r\n\t}\r\n\tpublic String getFs() {\r\n\t\treturn fs;\r\n\t}\r\n}\r\n```\r\n\r\nBoot 1.3.0.M2 CLI\r\n```\r\n$ ~/bin/bootclis/spring-1.3.0.M2/bin/spring run App1.groovy \r\n\r\n  .   ____          _            __ _ _\r\n /\\\\ / ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\r\n( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\r\n \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\r\n  '  |____| .__|_| |_|_| |_\\__, | / / / /\r\n =========|_|==============|___/=/_/_/_/\r\n :: Spring Boot ::             (v1.3.0.M2)\r\n\r\n2015-08-11 13:39:58.582  INFO 1651 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on cypher with PID 1651 (/home/jvalkealahti/.m2/repository/org/springframework/boot/spring-boot/1.3.0.M2/spring-boot-1.3.0.M2.jar started by jvalkealahti in /home/jvalkealahti/work/cli-apps/env-test)\r\n2015-08-11 13:39:58.703  INFO 1651 --- [       runner-0] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1265f16: startup date [Tue Aug 11 13:39:58 BST 2015]; root of context hierarchy\r\n2015-08-11 13:39:59.266  INFO 1651 --- [       runner-0] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup\r\nfs=myvar\r\n2015-08-11 13:39:59.324  INFO 1651 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 0.887 seconds (JVM running for 1.907)\r\n2015-08-11 13:39:59.325  INFO 1651 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1265f16: startup date [Tue Aug 11 13:39:58 BST 2015]; root of context hierarchy\r\n2015-08-11 13:39:59.325  INFO 1651 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown\r\n```\r\n\r\nBoot 1.3.0.M3 CLI\r\n```\r\n$ ~/bin/bootclis/spring-1.3.0.M3/bin/spring run App1.groovy \r\n\r\n  .   ____          _            __ _ _\r\n /\\\\ / ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\r\n( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\r\n \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\r\n  '  |____| .__|_| |_|_| |_\\__, | / / / /\r\n =========|_|==============|___/=/_/_/_/\r\n :: Spring Boot ::             (v1.3.0.M3)\r\n\r\n2015-08-11 13:40:05.741  INFO 1684 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on cypher with PID 1684 (/home/jvalkealahti/.m2/repository/org/springframework/boot/spring-boot/1.3.0.M3/spring-boot-1.3.0.M3.jar started by jvalkealahti in /home/jvalkealahti/work/cli-apps/env-test)\r\n2015-08-11 13:40:05.849  INFO 1684 --- [       runner-0] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1d8280a: startup date [Tue Aug 11 13:40:05 BST 2015]; root of context hierarchy\r\n2015-08-11 13:40:06.436  INFO 1684 --- [       runner-0] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup\r\nfs=null\r\n2015-08-11 13:40:06.499  INFO 1684 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 0.913 seconds (JVM running for 1.886)\r\n2015-08-11 13:40:06.509  INFO 1684 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1d8280a: startup date [Tue Aug 11 13:40:05 BST 2015]; root of context hierarchy\r\n2015-08-11 13:40:06.510  INFO 1684 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown\r\n```"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/129875834","html_url":"https://github.com/spring-projects/spring-boot/issues/3724#issuecomment-129875834","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/3724","id":129875834,"user":{"login":"snicoll","id":490484,"avatar_url":"https://avatars.githubusercontent.com/u/490484?v=3","gravatar_id":"","url":"https://api.github.com/users/snicoll","html_url":"https://github.com/snicoll","followers_url":"https://api.github.com/users/snicoll/followers","following_url":"https://api.github.com/users/snicoll/following{/other_user}","gists_url":"https://api.github.com/users/snicoll/gists{/gist_id}","starred_url":"https://api.github.com/users/snicoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snicoll/subscriptions","organizations_url":"https://api.github.com/users/snicoll/orgs","repos_url":"https://api.github.com/users/snicoll/repos","events_url":"https://api.github.com/users/snicoll/events{/privacy}","received_events_url":"https://api.github.com/users/snicoll/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T13:36:53Z","updated_at":"2015-08-11T13:36:53Z","body":"Agreed, we should find out why it does not work anymore."}}