如何在Cloud Foundry中为Java应用程序添加多个目的地? [英] How to add multiple destinations for a java application in cloud foundry?

查看:103
本文介绍了如何在Cloud Foundry中为Java应用程序添加多个目的地?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用S4Hana SDK开发了Java应用程序.将应用程序部署到SAP Cloud平台后,我使用以下命令将目标设置为环境变量.

I developed a Java application using S4Hana SDK. After deploying the application to SAP Cloud platform, I set the destinations as an environment variable with below command.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"}]'

现在,我想为同一应用程序添加第二个目的地.有人可以帮我吗?

Now, I would like to add a second destination for the same application. Can someone please help me?

谢谢, Sankeerth

Thanks, Sankeerth

推荐答案

您可以在环境变量中定义多个目标.这是一个JSON数组.

You can define multiple destinations in the environment variable. It is a JSON array.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"},{name: "ErpQueryEndpoint2", url: "https://URL", username: "USER", password: "PASSWORD"}]'

在虚拟数据模型的execute方法中,您可以定义要使用的目标:

In the execute method in the virtual data model you can define which destination to use:

BusinessPartnerService service = new DefaultBusinessPartnerService();

final List<BusinessPartner> businessPartners =
        service.getAllBusinessPartner().execute(new ErpConfigContext("ErpQueryEndpoint2"));

但是,比使用环境变量更好的是使用目标服务.

However, better than using the environment variables is to use the destination service.

SDK教程的第4步介绍了如何使用此服务: https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/

Step 4 of the SDK tutorials explains how to use this service: https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/

这样甚至可以为每个租户提供目标配置.

With that it is even possible to have destination configurations per tenant.

这篇关于如何在Cloud Foundry中为Java应用程序添加多个目的地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆