Common Misconfigurations
- Using SNAPSHOT versions in production
- Not controlling snapshot update frequency
- Allowing snapshots from untrusted repositories
- Missing snapshot versioning policies
- Not locking snapshot versions before release
Vulnerable Example
Secure Solution
Key Commands for Managing Snapshots
These commands help you work with the secure snapshot lifecycle.1. Activating the Development Profile
To use the secure snapshot repository, you must activate thedevelopment profile shown in the example.
2. Forcing a Snapshot Update
Even with anupdatePolicy of daily, you may need to force Maven to check for a newer snapshot. The -U flag does this.
3. Enforcing No Snapshots
To manually run the enforcer plugin (as shown in the “Secure Solution”) and fail the build if any snapshot dependencies are found:verify or package phase, but you can run it manually to check.
4. Converting Snapshots to Releases (The “Lock”)
When you are ready to release, you must convert all1.0-SNAPSHOT versions to a stable 1.0.0 version. The versions-maven-plugin is great for this.
5. Starting the Next Development Cycle
After the release, you need to change the version from1.0.0 to 1.1-SNAPSHOT (or similar).
maven-release-plugin (mvn release:prepare) automates steps 4 and 5, but these are the underlying commands.
Best Practices
- Never use SNAPSHOT dependencies in production.
- Implement strict snapshot policies.
- Use Maven Enforcer Plugin to prevent snapshot usage.
- Lock versions before releases.
- Use separate repositories for snapshots and releases.

