【TIPS】在maven项目中配置仓库后找不到依赖的解决办法
找不到geotools依赖
在项目中添加了项目的geotools依赖,但是却找不到geotools,发现是阿里云maven镜像上面没有这个包,所以需要从其他的镜像中获取。
解决
所以需要在pom中配置其他镜像,这里我配置了osgeo的镜像:
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
但是,刷新之后还是找不到geotools,这时,需要修改maven中setting.xml配置文件mirrorOf标签的配置,需要修改为如下,表示先从id为osgeo的镜像中查找,如果查找不到再从默认的阿里云镜像中查找:
<mirror>
<id>aliyun</id>
<name>aliyun Maven</name>
<mirrorOf>*,!osgeo</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>