When building Spring Boot projects using Maven, if you want to force pull dependencies every time you package it, you can do this by doing it.
Method 1: Force update dependencies on the command line
Executionmvn package
ormvn install
When waiting for the command, add-U
Parameters:
mvn clean package -U
-U
The function is to force update dependencies (Update Snapshots), make sure to re-pull the latest version of the dependency every time.
Method 2: Modify the Maven configuration file
If you want to implement it through configuration, you can use Maven'sThe following configurations are added to the file:
<settings> <profiles> <profile> <id>force-update</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <>always</> </properties> </profile> </profiles> </settings>
Then use the following command:
mvn clean package -Pforce-update
Method 3: Update the snapshot strategy of Maven local repository
existModify the repository in the file
<snapshot>
Configure, force check for updates every time you build:
<repositories> <repository> <id>central</id> <url>/maven2</url> <snapshots> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories>
This way Maven checks for updates to the SNAPSHOT version every time it builds.
Method 4: Clear the SNAPSHOT cache of the local repository
Manually delete Maven local repositorySNAPSHOT
The cache of the version to ensure re-downloads every time:
rm -rf ~/.m2/repository/<your-group-id>/<artifact-id>
Things to note
- Frequent pulling may affect construction efficiency: Forced pulling dependencies each time will increase network request time, and it is recommended to use only if necessary.
-
Ensure version management specifications: For the development version, it is recommended to use
-SNAPSHOT
Suffix, which can be automatically updated when a new snapshot version is released by the remote repository.
Overall, the easiest way is to use the command line-U
Parameters, which are both convenient and will not affect performance for a long time.
The above is the detailed implementation of the method of re-pulling maven dependencies before SpringBoot is packaged. For more information about re-pulling maven before SpringBoot is packaged, please follow my other related articles!