我正在开发一个将与多个端点连接的 API。每个端点的 uri 是这样的:
rest/services/General/directory1/MapServer/export
rest/services/General/directory2/MapServer/export
rest/services/General/directory3/MapServer/export
rest/services/General/directory4/MapServer/export
等等...
我不知道这是否可能,但希望有这样的东西:
rest/services/General/${value}/MapServer/export
然后在我的代码中只需调用上面的端点,注入(inject)我想要的特定目录 ${value}
这可能吗?当我用谷歌搜索但找不到任何相关内容时,不知道我错过了什么。
干杯
最佳答案
您可以通过 Spring Cloud Config 来完成此操作。
Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
有关更多详细信息,请参阅 spring 文档 here .
关于java - 是否可以在运行时更改 Spring Boot 中 property.file 内的特定值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54033819/