Depending on Snapshots
If you are developing a program that depends on a frequently changing dependency, you might want to depend on the latest build instead of hardcoding a version for each dependency. This can be especially useful when a project depends on a dependency which is still a beta of a release candidate, or if you are developing a series of interdependent Maven projects, as discussed in Chapter 3. In this lab, you'll learn how to depend on a SNAPSHOT.
How do I do that?
Instead of specifying a specific version in your dependency
block, use the keyword SNAPSHOT as
part of the version name. Every time you execute a Maven goal, Maven
will check for a new version of the dependency from the remote
repository. Maven will download the dependency if the remote
repository has a newer version than the local repository. For example,
the following dependency would always download the latest 1.2
development JAR of spring:
<dependency> <groupId>springframework</groupId> <artifactId>spring</artifactId> <version>1.2-SNAPSHOT</version> </dependency>
What just happened?
When you use SNAPSHOT dependencies you are telling Maven to use the latest version in the remote repository. This will come in handy when you are using the Multiproject plug-in, or when you are depending on an artifact still in development, as will often be the case if you're working on a team consisting of more than a few developers. You will be using SNAPSHOT dependencies when your project depends on the latest development ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access