Maven Setting Mirror
Maven Mirror specify from where dependencies should be downloaded. There is already repository tag is available but maven mirror used in specific condition. Let's see that.
Here, <mirrorOf> has significance to specify usage of mirror. for example, we want to specify single mirror for all the respository manager or all.
- Geographically closer mirror to get dependencies
- You want to represent repository which have better control of dependencies
- Need to provide local cache to repository manager
- In the organisation, to avoid external traffic we can use mirror.
Let's see the working of mirror.
The scenario is like, we have two repository first, Maven Central and second, Custom
- We have declared dependencies to an artifact.
- Maven will look into Custom repository.
- Dependencies is not found into the Custom repository.
- Maven will go to central repository. Maven will notice that mirror was configured for that repository. Maven will not go to central but it will go to mirror URL.
Following way we can declare, Mirror in settings.xml
- <settings>
- ...
- <mirrors>
- <mirror>
- <id>mirror</id>
- <name>Mirror Repository</name>
- <url>https://mirror.repo.com/maven2</url>
- <mirrorOf>central</mirrorOf>
- </mirror>
- </mirrors>
- ...
- </settings>
Here, <mirrorOf> has significance to specify usage of mirror. for example, we want to specify single mirror for all the respository manager or all.
Conclusion:
We can use mirror to provide local cache with repository manager. It helpful in case dependencies can not be download from central repository. We can use mirror to avoid traffic outside organisation network.
Comments
Post a Comment