How does Maven resolve SNAPSHOT dependencies when there are SNAPSHOTS with different timestamps in the local and the remote repository?

ぐ巨炮叔叔 提交于 2019-11-30 01:13:18

Artifacts that you just mvn install don't get a timestamp. A timestamp is applied once you mvn deploy to your internal/remote repository. If you look into the maven-metadata-local.xml in your local ~/.m2/repository/B/1.0.0-SNAPSHOT/ folder you'll see lines with:

<updated>YYYYMMDDHHMMSS</updated> 

This is how the Maven dependency resolver decides what the latest snapshot is.

If it happens that you and your colleague deploy to your internal/remote repository within the same second it's up to the repository manager – Nexus in your case – to handle this.

Please note: The paragraphs above rely on my experience with Maven since I haven't seen a docu page where this is described in all details so far. Inputs where to find a reference as well as additions and corrections are highly welcome.

See Maven / Introduction to Repositories for an overview.

If you want to assure that you use the latest snapshots:

„A timestamp after the SNAPSHOT part of the file name“ is unusual to me. AFAIHS it's either the one or the other only. Though this can happen if there is "-SNAPSHOT" in the <artifactId> in your project's POM.

UPDATE

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!