0

I'm using the Java extension for VSCode while working in a maven project. We have a private maven repository that is accessible over VPN, specified in my .m2 settings:

$ cat ~/.m2/settings.xml
... // some hidden things
<mirrors>
  <mirror>
    <id>nexus</id>
    <name>Mirror</name>
    <url>http://****/nexus/repository/public</url> // accessible only over our company's VPN
    <mirrorOf>external:*,!dynamodb-local-oregon</mirrorOf>
  </mirror>
</mirrors>

I can successfully add and install dependencies stored either on our Nexus repo or from maven central.

But every time I start VSCode, it complains that it cannot find a private dependency, and I have to refresh the Java project, which requires that I be on VPN and that I redownload the missing dependency. Other dependencies, like lombok or google cloud, never have this problem--or if they do they don't need to be on VPN to download them again. The "missing" dependency is definitely downloaded into my .m2 folder:

$ ls ~/.m2/repository/com/company/data/dependency
total 0
drwxr-xr-x  18 user  staff  576 27 Jan 11:15 4.3.2-SNAPSHOT/

Why does VSCode "forget" about the dependency when I've already downloaded it and used it during previous sessions, and why do I need to download it again?

EDIT: It looks like because the dependency is a snapshot, it will try to download the most up to date version. Is there a way to make it silently fallback to using the existing artifact in my ~/.m2 folder when it cannot download a new version? I'm not sure why these versions are snapshots, since they don't change all that often.

whiterook6
  • 3,270
  • 3
  • 34
  • 77
  • Does this answer your question? [What exactly is a Maven Snapshot and why do we need it?](https://stackoverflow.com/questions/5901378/what-exactly-is-a-maven-snapshot-and-why-do-we-need-it) – Thomas Kläger Feb 11 '22 at 20:19
  • Specifically this is the expected behaviour for Maven, see https://stackoverflow.com/a/5907727/5646962 – Thomas Kläger Feb 11 '22 at 20:20
  • @ThomasKläger Is there a way in VSCode to silently use the existing artifact instead of throwing an error and complaining that it cannot find the newest version? – whiterook6 Feb 16 '22 at 18:59

1 Answers1

1

The solution is provided in the link in @ThomasKläge's comment:

solution

Mia Wu-MSFT
  • 182
  • 6