我能够通过配置一个Bean
类型成功地做到这一点VaultProperties
。下面是代码片段,它完全消除了在bootstrap.yml
@Configuration
public class VaultConfiguration {
@Bean
public VaultProperties vaultProperties() {
VaultProperties vaultProperties = new VaultProperties();
vaultProperties.setAuthentication(VaultProperties.AuthenticationMethod.APPROLE);
VaultProperties.AppRoleProperties appRoleProperties = new VaultProperties.AppRoleProperties();
appRoleProperties.setRoleId("****");
appRoleProperties.setSecretId("****");
vaultProperties.setAppRole(appRoleProperties);
vaultProperties.setHost("***");
vaultProperties.setPort(80);
vaultProperties.setScheme("http");
return vaultProperties;
}
}
注意:当您有一个应该被视为引导配置的配置时,您需要在下面提及类名src/main/resources/META-INF/spring.factories
里面的内容spring.factories
是
org.springframework.cloud.bootstrap.BootstrapConfiguration=com.arun.local.cloudconfig.VaultConfiguration