GeoTools依賴使用Maven下載失敗解決辦法記錄


我們在使用Maven的時候經常會遇到依賴下載失敗的情況,大部分原因是由於網絡連接超時,因此我們一般在配置文件中都會使用阿里的鏡像地址:

<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>central</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

但是阿里的鏡像中並沒有關於GeoTools的依賴,在此不去探究沒有此依賴的原因。

現記錄一下我是如何解決此問題的:

方法一:直接去官網下載,然后手動拷貝到本地倉庫對應位置,然后點擊idea中右側的重新加載maven項目。

方法二(推薦):在pom.xml中加入osgeo的倉庫地址(注意setting中阿里雲鏡像的參數應為<mirrorOf>central</mirrorOf>):

 

    <repositories>
        <repository>
            <id>osgeo</id>
            <name>OSGeo Release Repository</name>
            <url>https://repo.osgeo.org/repository/release/</url>
            <snapshots><enabled>false</enabled></snapshots>
            <releases><enabled>true</enabled></releases>
        </repository>
        <repository>
            <id>osgeo-snapshot</id>
            <name>OSGeo Snapshot Repository</name>
            <url>https://repo.osgeo.org/repository/snapshot/</url>
            <snapshots><enabled>true</enabled></snapshots>
            <releases><enabled>false</enabled></releases>
        </repository>
    </repositories>

 

方法三:在Maven的settings.xml中阿里鏡像同級位置添加osgeo倉庫地址,(osgeo-snapshot、GeoSolutions也可參考下面的方法,此方法貌似不對,但是能解決一部分人jar下載失敗的問題)

<mirror>
    <id>osgeo</id>
    <mirrorOf>osgeo</mirrorOf>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
</mirror>

其他依賴下載不下來的時候也可以參考此方法。

希望對大家有幫助,如果還有其他更好的辦法歡迎留言互相學習。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM