无法访问com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces中的私有类

时间:2018-04-06 19:34:06

标签: s4sdk

我正在尝试按照SDK教程中的步骤20创建一个实体。但是当我使用命令mvn clean install

构建项目时

我添加了以下可用的导入 https://help.sap.com/http.svc/rc/05fbf11f8ccc403dba4f90150e8f4ccf/1.0/en-US/index.html?com/sap/cloud/sdk/s4hana/datamodel/odata/namespaces/package-summary.html

import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.AddressEmailAddress;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartnerAddress;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartnerRole;

我看到以下错误。

  

[ERROR]   /C:/Users/sanke/workspace/Businesspartners_cloudfoundry/application/src/main/java/com/yash/cf/Businesspartners_cloudfoundry/BusinessPartnerServlet.java:[81,17]   toEmailAddress(java.util.List中)   有私人访问权限   com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartnerAddress.BusinessPartnerAddressBuilder   [错误]   /C:/Users/sanke/workspace/Businesspartners_cloudfoundry/application/src/main/java/com/yash/cf/Businesspartners_cloudfoundry/BusinessPartnerServlet.java:[93,17]   toBusinessPartnerAddress(java.util.List中)   有私人访问权限   com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner.BusinessPartnerBuilder   [错误]   /C:/Users/sanke/workspace/Businesspartners_cloudfoundry/application/src/main/java/com/yash/cf/Businesspartners_cloudfoundry/BusinessPartnerServlet.java:[94,17]   toBusinessPartnerRole(java.util.List中)   有私人访问权限   com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner.BusinessPartnerBuilder

1 个答案:

答案 0 :(得分:5)

博客仍然引用1.5.0版。您遇到的错误表明您使用的是更新版本&gt; = 1.6.0,其中导航属性的签名稍有变化。例如,代替toEmailAddress(List<AddressEmailAddress> value)的方法已经重新设计为emailAddress(AddressEmailAddress... value)。有关此事,请参阅release notes for 1.6.0

因此,请将您的代码更改为以下内容:

final BusinessPartnerAddress businessPartnerAddress = BusinessPartnerAddress.builder()
    .country(country)
    .cityName(city)
    .emailAddress(emailAddress)
    .build();

该教程也已更新。