Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - How to find correct groupId/artifactId to include dependency in POM

Tags:

maven-2

maven

In general, what is the best strategy for finding the groupId and artifactId for a well-known dependency for use in a Maven POM? For example, how would I find the correct entry for the MySQL JDBC driver? It's not mentioned on the mysql.com site, so I would usually spend time looking for another POM that already uses the Maven repository version of the jar. This can't be the best way.

like image 314
visitor93746 Avatar asked Aug 25 '10 12:08

visitor93746


People also ask

What should be the groupId and artifactId in Maven?

Maven uses a set of identifiers, also called coordinates, to uniquely identify a project and specify how the project artifact should be packaged: groupId – a unique base name of the company or group that created the project. artifactId – a unique name of the project. version – a version of the project.

What should be the artifactId in Maven?

artifactId is the name of the jar without version. If you created it, then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar, you have to take the name of the jar as it's distributed.

How do you determine dependency hierarchy?

Maven Dependency Tree in Eclipse IDExml “Dependency Hierarchy” tab shows the dependency tree of the project. It has two sides - the left side shows verbose output and the right side shows the resolved dependencies. We can use the “Filter” option to look for a specific dependency.

Why do I need multiple pom dependencies in Maven?

Sometimes it makes more sense to group similar dependencies together and reference a pom dependency. This way, your project can reference as many of these consolidated dependency POMs as it needs. Maven uses the depth of a dependency in the tree when resolving conflicts using a nearest-wins approach.

What is dependency grouping in Maven?

Maven uses the depth of a dependency in the tree when resolving conflicts using a nearest-wins approach. Using the dependency grouping technique above pushes those dependencies one level down in the tree. Keep this in mind when choosing between grouping in a pom or using dependencyManagement in a parent POM

How do I view dependencies in Maven?

One of Maven’s main jobs is to handle your Java project’s dependencies. So when Maven runs, it builds a “tree” of all dependencies in your project. If you tell Maven to print a dependency tree, you will be able to see all of the dependencies in your project. Drop to a terminal.

How do I build a Maven project from a POM file?

For example, the entire Maven core runs through a single base POM org.apache.maven:maven, so building the Maven project can be executed by a single command: mvn compile. However, an aggregator project and a parent project are both POM projects, they are not one and the same and should not be confused.


2 Answers

I would suggest to use http://search.maven.org

like image 197
khmarbaise Avatar answered Oct 23 '22 02:10

khmarbaise


M2Eclipse, the maven integration of eclipse, supports local searchable indexes of maven repositories. So you can right-click a project or a pom.xml and do

Maven -> Add Dependency 

A dialog appears where you can search for artifacts from your local indexes. Wouldn't want to miss it.

If that's not an option, use mvnrepository.com

like image 24
Sean Patrick Floyd Avatar answered Oct 23 '22 01:10

Sean Patrick Floyd