我有一个使用 Stripe API 的程序。我正在尝试设置一个将位于 .gitignore 中的 secrets.yml 文件。这是我目前的尝试:
秘密.yml:
stripe:
STRIPE_PUBLIC_KEY: key1
STRIPE_SECRET_KEY: key2
相关的application.properties:
spring.profiles.include=secrets
spring.config.additional-location=classpath:secrets.yml
两个文件都在
src/main/resource/
这是Java代码:
@Value("${STRIPE_SECRET_KEY}")
private String secretKey;
@Value("${STRIPE_PUBLIC_KEY}")
private String stripePublicKey;
当密钥在 application.properties 中时,程序可以正常工作。