我有一个SAP应用程序,我试图使用sap-cf包从CAP应用程序发送电子邮件。
正如示例中提到的,我在BTP中创建了一个目标服务,当我试图将应用程序部署到BTP时,它失败了。
当我使用cds watch在本地运行应用程序时,它会给出以下错误
VError:没有与目的地匹配的服务
这是我的mta.yaml
## Generated mta.yaml based on template version 0.4.0
## appName = CapTest
## language=nodejs; multitenant=false
## approuter=
_schema-version: '3.1'
ID: CapTest
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production
modules:
# --------------------- SERVER MODULE ------------------------
- name: CapTest-srv
# ------------------------------------------------------------
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
requires:
# Resources extracted from CAP configuration
- name: CapTest-db
- name: captest-destination-srv
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
# -------------------- SIDECAR MODULE ------------------------
- name: CapTest-db-deployer
# ------------------------------------------------------------
type: hdb
path: gen/db
parameters:
buildpack: nodejs_buildpack
requires:
# 'hana' and 'xsuaa' resources extracted from CAP configuration
- name: CapTest-db
resources:
# services extracted from CAP configuration
# 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
# ------------------------------------------------------------
- name: CapTest-db
# ------------------------------------------------------------
type: com.sap.xs.hdi-container
parameters:
service: hana # or 'hanatrial' on trial landscapes
service-plan: hdi-shared
properties:
hdi-service-name: ${service-name}
- name: captest-destination-srv
type: org.cloudfoundry.existing-service这是CDS服务的js文件。
const cds = require('@sap/cds')
const SapCfMailer = require('sap-cf-mailer').default;
const transporter = new SapCfMailer("MAILTRAP");
module.exports = cds.service.impl(function () {
this.on('sendmail', sendmail);
});
async function sendmail(req) {
try {
const result = await transporter.sendMail({
to: 'someoneimportant@sap.com',
subject: `This is the mail subject`,
text: `body of the email`
});
return JSON.stringify(result);
}
catch{
}
};我在下面的样本中找到这个
发布于 2022-01-12 13:59:55
您是否创建了默认的..。json文件?它们需要连接到BTP租户上的远程服务。你可以在SAP博客上找到更多有关这方面的信息,比如:https://blogs.sap.com/2020/04/03/sap-application-router/。
还可以使用sap-cf-localenv命令:https://github.com/jowavp/sap-cf-localenv。
据我所知,这个工具是实验性的,只适用于CLI V6。更高版本正在以另一种格式获取服务键,这将导致命令失败。
你好,托马斯
https://stackoverflow.com/questions/69823453
复制相似问题