How to look for the maven repository of a particular class or package

117 views Asked by At

In my Maven project, I need to use a particular class (specifically, org.eclipse.rdf4j.model.util.Values.bnode) However, when I import it in Eclipse it logically complains it couldnt find it. Further, when I look for the Maven repo of rdf4j in https://mvnrepository.com/, I find a bunch of them and I dont know which one contains the class I am looking for.

So my question is : is there a simple way to look for the Maven repository that contains a certain class or package?

Thx in advance

BTW. I found this class in an online tutorial. But the turorial does not give the maven configuration or the package information, which is not convenient at all. Tutos should always mention how to set the environment and import specific packages (or at least point to another webpage that does).

2

There are 2 answers

0
James Baxter On

Personally I try to find the source repo for the project that contains the class, then I look at the maven configuration (ie pom.xml) to see what groupId/artifactId it's published under.

Sometimes you will need to look at older git tags if the class has moved and/or been deleted.

0
Jeen Broekstra On

Looking at the specific project website is usually a good idea if somehow these dependencies are not automatically found.

In this case, the RDF4J project gives instructions on how to get the right maven artifacts on its download page. You can also look in the Github repo, if you search for the class file (Values.java in this case) you can see what package and module it's in: it's in the rdf4j/core/model directory, which has a module POM that gives you the details of the specific maven artifact:

    <groupId>org.eclipse.rdf4j</groupId>
    <artifactId>rdf4j-model</artifactId>