Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gson dependency - which repository?

Tags:

maven

gson

I must have a big blank in my knowledge of Maven, because I run into this problem on a regular basis...

I want to use Gson library (https://code.google.com/p/google-gson/) in my project. I added the following dependency to my pom.xml, as per the project's homepage:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.3</version>
</dependency>

That's nice. However, the dependency is not found by Eclipse. And that kinda makes sense. Where would it look for it? Which repository? I have a number of repositories declared in the pom.xml, but maybe none of them contain Gson.

And this is really a general question. I'd say most projects I've seen so far do not say which repository the artifact is stored in. They only provide the XML element for the dependency. What am I missing here? Does the main Maven repo contain all artifacts ever released by anyone? Please help me understand why so many projects do not say which repository their artifacts are stored in.

And if you could also tell me where do I find Gson artifact - I'd greatly appreciate it.

like image 968
anton1980 Avatar asked Nov 02 '14 16:11

anton1980


People also ask

What is the use of Gson dependency?

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.

What is the difference between Gson and Jackson?

Both Gson and Jackson are good options for serializing/deserializing JSON data, simple to use and well documented. Advantages of Gson: Simplicity of toJson/fromJson in the simple cases. For deserialization, do not need access to the Java entities.

Is Gson better than JSON?

GSON can use the Object definition to directly create an object of the desired type. While JSONObject needs to be parsed manually.


1 Answers

Maven searches by default for artifacts in Maven Central.

I can find this artifact in Maven Central: http://search.maven.org/#artifactdetails%7Ccom.google.code.gson%7Cgson%7C2.3%7Cjar

In your settings.xml you tell maven which are the repos you wanna search in, if you have "special" repos. There, you can configure username/passwords for these repos in case you need to upload JARs to your repo.

So if your maven cannot find it, paste here your settings.xml - maybe it is misconfigured.

BTW: does this help? GSON is not being imported into the maven pproject

like image 182
OhadR Avatar answered Oct 16 '22 13:10

OhadR