Before Maven, getting a common library like log4j meant browsing to the Apache website and downloading the latest binary. Now, with Maven, we don't have to scurry around the web collecting various library dependencies; we can simply specify the dependency in our Maven POM and the let the Maven system do the rest.
But sometimes, it is not easy to know how to define the library dependency in the POM. One technique I like to use is just to browse the Maven 2 Repository directly by pointing my web browser to the following URL: http://repo1.maven.org/maven2/
Suppose we would like to add the latest log4j library to our POM, for example. I can simply browse the Maven 2 repository index and click on the link for log4j. Once in that area, I can easily see the latest version available. Here's the listing I get:
So, then I click on 1.2.15 (the latest version) to get the following listing:
And from here, I click on maven-metadata.xml to get the real information I need in order to declare the dependency in my POM:
I have the groupId, artifactId, and the latest version. So, I can declare the dependency in my POM as follows:
This handy technique can help you figure out how to declare dependencies for common libraries.