0

I generated the code using a maven plugin and the code does not compile. https://sap.github.io/cloud-sdk/docs/java/features/odata/generate-typed-odata-v2-and-v4-client-for-java I am using the odata V2 Plugin

I am not sure how to resolve this compilation issue:

The method getHttpClient(String) in the type HttpClientAccessor is not applicable for the arguments (HttpDestinationProperties)

Here is my pom file.

      <dependency>
          <groupId>com.sap.cloud.s4hana.datamodel</groupId>
          <artifactId>odata-core</artifactId>
          <version>2.28.0</version>           </dependency>


          <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->            <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
          <version>1.18.22</version>          </dependency>
          <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->           <dependency>
          <groupId>javax.inject</groupId>
          <artifactId>javax.inject</artifactId>
          <version>1</version>            </dependency>
com.sap.cloud.sdk.datamodel odata-generator-maven-plugin 3.59.0
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

1 Answers1

0

You're referring to correct documentation but the version number is your pom is incorrect.

In the documentation, it says 3.x.x, which as of 10.12.2022 would be 3.59.0.

<plugin>
    <groupId>com.sap.cloud.sdk.datamodel</groupId>
    <artifactId>odata-generator-maven-plugin</artifactId>
    <!-- Please use the latest version here-->
    <version>3.XX.X</version>
    <executions>
        <execution>
            <id>generate-consumption</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputDirectory>${project.basedir}/edmx</inputDirectory>
                <outputDirectory>${project.build.directory}/vdm</outputDirectory>
                <deleteOutputDirectory>true</deleteOutputDirectory>
                <packageName>com.mycompany.vdm</packageName>
                <defaultBasePath>odata/v2/</defaultBasePath>
                <compileScope>COMPILE</compileScope>
                <serviceMethodsPerEntitySet>true</serviceMethodsPerEntitySet>
                <!-- (Optional) You can add a custom copyright header:
                <copyrightHeader>Copyright (c) this year, my company</copyrightHeader>

                Or use the SAP copyright header:
                <sapCopyrightHeader>true</sapCopyrightHeader>
                -->
            </configuration>
        </execution>
    </executions>
</plugin>

It feels like you're using an existing project based on an outdated and deprecated SDK version. Could you try generating a new project and use the maven plugin from there?

You can also check out if the service you're going to use has a pregenrated client library on the SAP API Business Hub. Check this one for example https://api.sap.com/api/API_COSTCENTERACTIVITYTYPE_SRV/cloud-sdk/Java

Artyom Kovalyov
  • 374
  • 3
  • 11