background
The department you are in mainly provides basic components for other project groups. If new features are needed, other project groups will often refer to SNAPSHOT version components for development and testing.
When I usually do my own tests, because I have the source code in my hand, I always execute mvn install and then test it in the new project after local installation, so I didn’t find any problems.
This time I didn't install it locally, but I couldn't pull it down. The console kept reporting the following error:
Could not find artifact xxx:jar:1.21.0-SNAPSHOT
Try to run Maven import with -U flag (force update snapshots)
It was invalid to perform forced pull according to the prompts, so I studied how other projects in the company were configured, and then successfully pulled this component.
Solution
Maven does not support pulling SNAPSHOT dependencies by default. You need to add the <repositories> tag to the project root and configure SNAPSHOT to enable.
As shown below:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="/POM/4.0.0" xmlns:xsi="http:///2001/XMLSchema-instance" xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0."> <modelVersion>4.0.0</modelVersion> <groupId></groupId> <artifactId>maven-snapshot</artifactId> <version>1.0.0</version> <properties> <>8</> <>8</> <>UTF-8</> </properties> ... <repositories> <repository> <!-- IDRequired --> <id>my-snapshots</id> <!-- MavenPrivate serverSNAPSHATstorehouseURL,这里需要替换为实际公司的Private server地址 --> <url>http://HOST:PORT/repository/maven-snapshots/</url> <!-- Settings EnableSNAPSHOT --> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> ... </project>
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.