Can Spring set datasource from service discovery?

Viewed 243

Before I start trying to programmatically set datasource configuration in my app using service discovery, I would like to be sure this functionality is not already managed by Spring.

In my case I am using Consul as the discovery service. So I read http://cloud.spring.io/spring-cloud-consul/1.0.x/index.html but don't really find something to answer my question (prolly because of my flawed knowledge of Spring configuration itself).

Basically I would configure the discovery system in a bootstrap.yml file

spring:
  cloud:
    consul:
      host: localhost
      port: 8500

then in the application.yml I would set something like:

spring:
  datasource:
    url: jdbc:${consul.service.datasource}

Is this possible "natively". If not, what do I miss in the concepts involved?

0 Answers
Related