Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import GsonFactory in maven

I have been looking all over to why i cannot use Gson in particular gsonFactory from any library i use.

I am using eclipse, my project has maven and I am running OS X

I am looking at this guide Authenticate with a backend server and whenever i try and create jsonFactory = new GsonFactory(); the GsonFactory cannot be resolved.

Now I have added several libraries as maven dependencies to no avail,

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.20.0</version>
</dependency>

<dependency>
  <groupId>com.google.http-client</groupId>
  <artifactId>google-http-client</artifactId>
  <version>1.19.0</version>
</dependency>

and also downloaded several jars but none of them resolve GsonFactory.

like image 839
SJC Avatar asked Dec 14 '22 08:12

SJC


1 Answers

That class is part of the GSON extensions to Google HTTP client library. So you just need to add a dependency for it. The current latest version is 1.21.0, so you could have:

<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-gson</artifactId>
    <version>1.21.0</version>
</dependency>
like image 184
Tunaki Avatar answered Jan 01 '23 00:01

Tunaki