title: Dynamicly operate on application properties - vault settings (or any other values)
body: <p>I would like to be able to flexibly choose between 3rd party components my application is using. ATM I have hardcoded values</p>
  
  <pre><code>spring.cloud.vault.token=ffffffff-ffff-ffff-ffff-ffffffffffff
  spring.cloud.vault.scheme=http
  spring.cloud.vault.application-name=test
  spring.cloud.vault.host=127.0.0.1
  spring.cloud.vault.port=8200
  </code></pre>
  
  <p>Goal is to : </p>
  
  <ul>
  <li>If <code>spring.cloud.vault.host</code> is set try to use it. If <code>spring.cloud.vault.host</code> is empty use
  local DB instead (with proper configuration)</li>
  </ul>
  
  <p>My first thought was to use <code>environment</code> variables like:</p>
  
  <pre><code>spring.cloud.vault.token=${VAULT_TOKEN}
  spring.cloud.vault.scheme=${VAULT_SCHEME}
  spring.cloud.vault.application-name=${VAULT_APP_NAME}
  spring.cloud.vault.host=${VAULT_HOST}
  spring.cloud.vault.port=${VAULT_PORT}
  </code></pre>
  
  <p>and later use component class like:</p>
  
  <pre><code>@Component
  public class VaultHelper {
      private final VaultOperations vaultOperations;
      @Value("${spring.cloud.vault.host}")
      String vaultHostname;
  
      @Autowired
      public VaultHelper(VaultOperations vaultOperations){
          this.vaultOperations = vaultOperations;
      }
  
      public void saveToVault(String password){
          if (!vaultHostname.equals("")) { 
              // Use vaultOperations to store password
          } else {
              // Use plaintext db storage
          }
      }
  
      public byte[] readFromVault(String passwordLoc){
          if (!vaultHostname.equals("")) {
              // Use vaultOperations to access password
          } else {
              // return plaintext password
          }
          return new byte[0];
      }
  
  
  }
  </code></pre>
  
  <p>This way I could set <code>${VAULT_HOST}</code> both from environment variable (running application from docker-compose) or just set <code>--spring.cloud.vault.host=URL</code> on local machine as <code>java</code> parameter.</p>
  
  <p>Unfortunately I get exception while unparsing <code>${VAULT_PORT}</code> field </p>
  
  <pre><code>Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [int] for value '${VAULT_PORT}'; nested exception is java.lang.NumberFormatException: For input string: "${VAULT_PORT}"
      at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:191) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:170) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.Binder.bindProperty(Binder.java:435) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:380) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
      ... 83 common frames omitted
  Caused by: java.lang.NumberFormatException: For input string: "${VAULT_PORT}"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_231]
      at java.lang.Integer.parseInt(Integer.java:569) ~[na:1.8.0_231]
      at java.lang.Integer.valueOf(Integer.java:766) ~[na:1.8.0_231]
      at org.springframework.util.NumberUtils.parseNumber(NumberUtils.java:211) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.core.convert.support.StringToNumberConverterFactory$StringToNumber.convert(StringToNumberConverterFactory.java:62) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.core.convert.support.StringToNumberConverterFactory$StringToNumber.convert(StringToNumberConverterFactory.java:49) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.core.convert.support.GenericConversionService$ConverterFactoryAdapter.convert(GenericConversionService.java:436) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      ... 90 common frames omitted
  
  
  Process finished with exit code 1
  </code></pre>
  
  <p>could anyone give me a hint how to make it work?</p>