从external secrets.txt中获取用户名/密码属性到app.yaml: spring boot中的DB2数



从external secrets.txt中获取用户名/密码属性到app.yaml中的DB2数据源:spring boot

Java文件:

@PropertySource(factory = YamlPropertySourceFactory.class, value = "${secrets.filepath}")
public class XyzApplication extends SpringBootServletInitializer {
@Value("${spring.datasource.username}")
private String username;

@Value("${spring.datasource.password}")
private String password;

App.yml:

secrets:
filepath: file:src/main/resources/secrets/secret.txt

​Spring:
datasource:
url: jdbc:some db conn path
username: username (??)
password: password (??)

Secrets.txt

spring.datasource.username: abcd
spring.datasource.password: p@ssWord

但是用户名,密码不能从secret.txt到app.yml

请提出任何更正或替代

从spring中删除用户名/密码。运行你的应用-是的,奇迹将会发生:)

​Spring:
datasource:
url: jdbc:some db conn path
username: username (remove this)
password: password (remove this)

相关内容

  • 没有找到相关文章

最新更新