Part X: Managing Dependencies

Except for the simplest of projects, it's likely that your Java application is going to rely on third-party libraries. Maven provides a powerful mechanism for defining the dependencies of your project, letting you control wether they are needed at compile, test and/or run-time and wether they should be bundled up with your final package.

  • compile
  • provided
  • runtime
  • test
  • system

In order for Maven to find the dependency artifact you want to use, you'll need to provide the groupId, artifactId and version that identifies it. You could waste time clicking through the directory structure of http://repo1.maven.org/maven2/ looking for it but there are better solutions out there.

The first place to check would be the official site of the project you want to use. For example, the documentation for Simple Logging Facade for Java (SLF4J) points you to its location in Maven's Central Repository at http://repo1.maven.org/maven2/org/slf4j/. You can dig into the specific version you need like http://repo1.maven.org/maven2/org/slf4j/slf4j-simple/1.6.1/ and look at the supplied pom.xml to get the coordinates to use it.