我浏览了很多关于此的教程,但无法完成。
这是我的表结构。
Application Profile Label prop_key value
masking dev latest test-property message
我有一个应该与 JDBC 后端集成的云配置服务器。这是我application.properties
的配置服务器
server.port=8082
spring.application.name=masking
management.endpoints.web.exposure.include=*
spring.datasource.url=jdbc:postgresql://localhost:8000/finos?currentSchema=xlabs
spring.datasource.username=mufgdev
spring.datasource.password=XXX
spring.profiles.active=XXX
spring.cloud.config.server.jdbc.sql=SELECT prop_key,value from xlabs.properties where application=? and profile=? and label=?
spring.cloud.config.server.jdbc.order=1
使用此配置,如果我输入http://localhost:8082/masking/dev/latest
响应将显示我想要的结果。
我想在客户端使用以下配置的属性bootstrap.properties
spring.application.name=masking
spring.cloud.config.uri=http://localhost:8082
spring.cloud.config.label=latest
spring.cloud.config.profile=dev
在我的客户端
@RestController
@RefreshScope
public class TestController {
@Value("${test-property}")
private String aConf;
@GetMapping("/message")
String message() {
String name =aConf ;
return name;
}
}
这给java.lang.IllegalArgumentException: Could not resolve placeholder 'test-property' in value "${test-property}"
任何人都可以对此发表评论吗?
谢谢。