Search code examples
javaapacheodataolingo

The import org.apache.olingo.commons.api.format.ODataFormat cannot be resolved


I have tried to run java project using OData Service in Apache Olingo API.

But I'm getting "import org.apache.olingo.commons.api.format.ODataFormat cannot be resolved" Error.

I know to import API path for corresponding Java file to solve this issue. But I couldn't found right one. Anyone helps to solve this issue.

The example file path: https://apache.googlesource.com/olingo-odata4/+/Tutorial_P4_Navigation/samples/tutorials/p1_read?autodive=0%2F%2F

enter image description here


Solution

  • Tutorial linked by you is based on 4.0.0-beta-03 version of Olingo. ODataFormat is not needed anymore.

    Instead

    ODataFormat format = ODataFormat.fromContentType(responseFormat);
    ODataSerializer serializer = odata.createSerializer(format);
    

    You can just go with

    ODataSerializer serializer = odata.createSerializer(responseFormat);
    

    responseFormat is of type ContentType in both cases.

    Code presented in the official tutorial is more up-to-date: https://olingo.apache.org/doc/odata4/index.html