首页 > 解决方案 > 如何将 SCP Neo 中目标服务的电子邮件配置绑定到 Spring Boot 应用程序?

问题描述

我想在 SAP Cloud Platform Neo 环境中部署一个 Spring Boot 应用程序。它有一个端点/sendmail,在调用时会向特定用户发送邮件。目前,我已将凭据硬编码在application.properties文件中,并且可以正常工作。该文件如下所示 -

spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=...
spring.mail.password=...
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000

现在,我想利用 SCP 平台的目标服务,我将在其中定义邮件帐户的凭据。我想从目标服务中获取凭据。那么,什么需要进入application.properties文件?

我在 SCP - Cloud Foundry 中执行了类似的操作,但针对不同的服务(数据库)。CF 具有可用于获取凭据的 VCAP 环境变量,如下所示 -

spring.datasource.url=${vcap.services.${vcap.services.name}.credentials.url}

在 Neo 中可以做同样的事情吗?

标签: javaspringspring-bootsap

解决方案


您可以使用 SAP S/4HANA Cloud SDK 检索目标及其属性。您可以在此处找到更多信息。


推荐阅读