{"action":"closed","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5110","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5110/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5110/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5110/events","html_url":"https://github.com/spring-projects/spring-boot/issues/5110","id":132278672,"number":5110,"title":"Allow Optional binding of @ConfigurationProperties","user":{"login":"enric-sinh","id":6584351,"avatar_url":"https://avatars.githubusercontent.com/u/6584351?v=3","gravatar_id":"","url":"https://api.github.com/users/enric-sinh","html_url":"https://github.com/enric-sinh","followers_url":"https://api.github.com/users/enric-sinh/followers","following_url":"https://api.github.com/users/enric-sinh/following{/other_user}","gists_url":"https://api.github.com/users/enric-sinh/gists{/gist_id}","starred_url":"https://api.github.com/users/enric-sinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enric-sinh/subscriptions","organizations_url":"https://api.github.com/users/enric-sinh/orgs","repos_url":"https://api.github.com/users/enric-sinh/repos","events_url":"https://api.github.com/users/enric-sinh/events{/privacy}","received_events_url":"https://api.github.com/users/enric-sinh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/feedback-provided","name":"feedback-provided","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-08T22:46:08Z","updated_at":"2016-02-09T10:19:55Z","closed_at":"2016-02-09T10:19:55Z","body":"It would be useful to be able to bind properties wrapped in Optional, like this:\r\n```java\r\n@ConfigurationProperties(prefix = \"hello\")\r\npublic class SomeProperties {\r\n\r\n  private Optional<String> anOptionalString;\r\n\r\n  private Optional<File> someOptionalFile;\r\n\r\n  // getters & setters\r\n\r\n}\r\n```\r\nI think that right now the property value remains `null` when it doesn't exist in the environment, which requires the developer to remember it is a nullable property (and to check for it).\r\n\r\nIn order to avoid this issue, one can specify a default value (e.g. `private String fruit = \"banana\"`).\r\n\r\nHowever, there are cases where it doesn't make sense to have a default, and with some types it feels wierd (e.g. default value for a `File` property)."}}