spring-cloud-config

Spring Config server add property at runtime

陌路散爱 提交于 2020-01-13 04:38:11
问题 I want to add some property at runtime in spring config server and it should be available to all client applications with @Value annotation. I wont have this property predefine because I am going calculate that value in spring config server and add to environment. Can you please help me understand what is best way to achieve this. 回答1: Spring cloud configuration contains a feature named 'RefreshScope' which allows to refresh properties and beans of a running application. If you read about

Spring Config server add property at runtime

五迷三道 提交于 2020-01-13 04:37:47
问题 I want to add some property at runtime in spring config server and it should be available to all client applications with @Value annotation. I wont have this property predefine because I am going calculate that value in spring config server and add to environment. Can you please help me understand what is best way to achieve this. 回答1: Spring cloud configuration contains a feature named 'RefreshScope' which allows to refresh properties and beans of a running application. If you read about

Spring cloud config server. Environment variables in properties

谁说胖子不能爱 提交于 2020-01-12 07:40:08
问题 I configured Spring Cloud Config server like this: @SpringBootApplication @EnableAutoConfiguration @EnableConfigServer public class ConfigServer { public static void main(String[] args) { SpringApplication.run(ConfigServer.class, args); } } I'm using 'native' profile so properties are picked up from the file system: server.port=8888 spring.profiles.active=native spring.cloud.config.server.native.search-locations: classpath:/global Now the tricky part is that some properties contain

Spring Cloud Config custom environment repository

感情迁移 提交于 2020-01-11 06:33:30
问题 I am wondering is there an example how to create a custom EnvironmentRepository for Spring Cloud Config, cause there are git, svn, vault repositories, but I don't wanna use them, I need my custom one. For instance if I just want to store all properties in a Map. 回答1: Provide an implementation of the EnvironmentRepository as a bean in your application context. Spring cloud config server then will pick it up automatically. Here's a minimalistic example: public class CustomEnvironmentRepository

HikariCP restart with Spring Cloud Config

孤街浪徒 提交于 2020-01-06 06:17:04
问题 I have recently configured my application to use Spring Cloud Config with Github as a configuration repository. Spring Boot - 2.1.1.RELEASE Spring Cloud Dependencies - Greenwich.RC2 My application is using pretty much everything out of the box. I have just configured the database in application.yml and I have HikariCP autoconfigurations doing the magic in the background. I am refreshing my applications using this job that calls refresh() method on the RefreshEndpoint. import org.slf4j.Logger;

spring : bypass contextPath for a specific controller

纵然是瞬间 提交于 2020-01-04 15:17:14
问题 I am building a Spring Cloud Config server and I use the property server.contextPath: /configServer but I also want my server to respond with 200 on any request to /ping (not /configServer/ping ). Is there any way to bypass the contextPath property for a specific RestController (or any other way to achieve that)? Thanks. 回答1: I found the solution to my problem: There is the spring property spring.cloud.config.server.prefix which does exactly what I was looking for. This prefix is like

spring : bypass contextPath for a specific controller

巧了我就是萌 提交于 2020-01-04 15:17:05
问题 I am building a Spring Cloud Config server and I use the property server.contextPath: /configServer but I also want my server to respond with 200 on any request to /ping (not /configServer/ping ). Is there any way to bypass the contextPath property for a specific RestController (or any other way to achieve that)? Thanks. 回答1: I found the solution to my problem: There is the spring property spring.cloud.config.server.prefix which does exactly what I was looking for. This prefix is like

Custom Spring config EnvironmentRepository not being picked up

烂漫一生 提交于 2020-01-03 05:03:34
问题 I'm trying to figure out why my custom Environment Repository (in an embedded mode Spring Config application i.e. no stand-along Config server) isn't being picked up. The object is obviously being constructed (I hit a log print statement at this point) but none of the properties I inject into it (from a hashmap for this example) show up in an env actuator dump i.e. custom.prop.* . The findOne(...) isn't being invoked. Dump at https://gist.github.com/balamuru/1047db7080a4da6f067dd7cfac86a2c2

How to configure a github repository as a config repo for spring cloud server?

百般思念 提交于 2020-01-03 04:21:04
问题 I have created a github repository https://github.com/Nisarg04/microservices-config-repo.git , which I want to be treated as a config repo. Also, I have a spring cloud server, which picks properties from local repo (as per current configuration). I want that to be picked from github repo. application.properties looks something like this : spring.application.name=spring-cloud-config-server server.port=8888 #spring.cloud.config.server.git.uri=file:///C:/Users/admin/git/git-localconfig-repo

How to use Spring Cloud Config with a Git and Vault composite environment repository?

妖精的绣舞 提交于 2020-01-02 05:46:11
问题 I've been tinkering with Spring Cloud Config, but have a use case where config properties are divided into two types: Non-secret values, which developers should be able to view and maintain (e.g. JDBC URL's, etc) Secret values, which should be viewed and maintained only by designated people with special access (e.g. passwords) So I'm very interested in the support for "Composite Environment Repositories", currently available in the snapshot versions. It seems like I would be able to use Git