Closed girish-jung closed 4 years ago
Please show your versions and configuration
Thanks for your quick response. Following is my bootstrap.properties file
#management.endpoints.web.exposure.include=refresh
#spring.cloud.config.enabled=false
spring.application.name=demo
spring.cloud.config.label=master
spring.profiles.active=jdbc
spring.cloud.config.server.bootstrap=true
Following is my application.properties file
spring.cloud.config.server.jdbc.sql= SELECT KEY, VALUE from PROPERTIES where APPLICATION=? and PROFILE=? and LABEL=?
spring.cloud.config.server.jdbc.order=1
spring.datasource.url=jdbc:postgresql://localhost:5432/testsdb
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.hikari.connectionTestQuery=SELECT 1
datasource.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
(Apart from the above config, I have normal application configs(properties) that I would like to move to DB, once this embedded server is able to configure itself works)
Why do we need to configure a git repository when we are using JDBC as a backend to load all the properties?
The problem is that the JDBC environment repository configuration isn't meeting all the conditions that are required, so it isn't getting created and the Config Server auto-configuration is defaulting to a git repository.
I think there's a problem with using JDBC with an embedded config server (i.e. spring.cloud.config.server.bootstrap=true
). The JDBC Config Server configuration depends on JdbcTemplate
and DataSource
beans in the application context, which are normally provided by Boot's JdbcTemplateAutoConfiguration
and DataSourceAutoConfiguration
. These auto-config classes do not appear to be getting run in the bootstrap application context before the Config Server EnvironmentRepositoryConfiguration
auto-configuration is run.
You can see this by setting the system property debug=true
when running the application and inspecting the CONDITIONS EVALUATION REPORT
in the application log output. I see EnvironmentRepositoryConfiguration
running, but failing the @ConditionalOnBean(JdbcTemplate.class)
condition. JdbcTemplateAutoConfiguration
and DataSourceAutoConfiguration
are not in the condition evaluation report at all.
I got further by forcing those auto-configuration classes to run in the bootstrap application context. As an experiment/potential temporary work-around you can create a /resources/META-INF/spring.factories
file in your project containing these lines:
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
and then inspect the CONDITIONS EVALUATION REPORT
to see if the JDBC repository configuration is working.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
See updated workaround here https://github.com/spring-cloud/spring-cloud-config/issues/1848#issuecomment-810441931
We have a requirement to read the application properties from the Database. To achieve this I am trying to use spring cloud. I am trying to embed the config server in a spring boot application with JDBC backend so that the application can configure itself by reading properties from the DB. But I am unable to configure bootstrap.properties file. I am getting the following error:- Thanks for raising a Spring Cloud issue. What sort of issue are you raising?
Caused by: java.lang.IllegalStateException: You need to configure a URI for the git repository. at org.springframework.util.Assert.state(Assert.java:73) at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:253) at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:66)
Why do we need to configure a git repository when we are using JDBC as a backend to load all the properties?