title: How can I use SpringBoot to pick up DB credentials from Vault?
body: <p>I have a <code>springboot</code> app that uses these versions:</p>
  <pre><code>SpringBoot: 2.3.1
  SpringCloud: Hoxton.SR5 
  SpringData: Neumann-SR1
  </code></pre>
  <p>I've used the custom class as described here (answer from @Arun): <a href="https://stackoverflow.com/questions/43983688/configuring-spring-cloud-vault-config-to-pull-from-a-location-other-than-secret">Configuring Spring Cloud Vault Config to pull from a location other than /secret</a></p>
  <p>It doesn't even seem to be picking up the vault configs.
  I have a <code>bootstrap.yml</code> with the following:</p>
  <pre><code>spring:
    cloud:
      # Vault configurations
      vault:
        generic:
          enabled: false
        uri: https://${URI}
        authentication: TOKEN
        token: ${VAULT_TOKEN}
  
      config:
        discovery:
          enabled: true
  </code></pre>
  <p>I'm trying to bring it up locally, so I have my <code>application.yml</code> as follows:</p>
  <pre><code>spring:
    datasource:
      url: jdbc:postgresql://localhost:8157/postgres
  
  </code></pre>
  <p>This is where I'm trying to inject the values from <code>vault</code> into my DataSource:</p>
  <pre><code>@Profile(value = {&quot;local&quot;, &quot;dev&quot;, &quot;stg&quot;, &quot;prd&quot;})
  @Configuration
  public class DatabaseConfig {
  
    @Autowired
    DatabaseCredentials config;
  
    @Bean
    @Primary
    public DataSource dataSource() {
  
      return DataSourceBuilder
          .create()
          .username(config.getUsername())
          .url(config.getUrl())
          .password(config.getPassword())
          .driverClassName(&quot;org.postgresql.Driver&quot;)
          .build();
    }
  }
  </code></pre>
  <p>When the app starts up, it <code>DatabaseCredentials</code> is empty.</p>
  <p>The other way I've done it is like this:</p>
  <pre><code>public class DatabaseConfig {
    
    @Value(&quot;${ccm.database.username}&quot;)
    String username;
  
    @Value(&quot;${ccm.database.password}&quot;)
    String password;
  
    @Value(&quot;${spring.datasource.url}&quot;)
    String url;
  
    @Bean
    @Primary
    public DataSource dataSource() {
      
      return DataSourceBuilder
          .create()
          .username(username)
          .url(url)
          .password(password)
          .driverClassName(&quot;org.postgresql.Driver&quot;)
          .build();
    }
  }
  </code></pre>
  <p>This has also come up empty saying it can't find a value for <code>ccm.database.username</code>.</p>
  <p>What am I doing wrong?</p>