IDEA設(shè)置maven修改settings.xml配置文件無(wú)法加載倉(cāng)庫(kù)的解決方案
出處:https://www.cnblogs.com/SunSpring
作為初學(xué)者配置maven一般網(wǎng)上搜索。然后你就看到各種配置文件片段,首先配置鏡像,然后配置倉(cāng)庫(kù)。完事后再IDEA里面配置下maven的路徑和配置文件路徑。
這些文章屬實(shí)坑爹,完全沒(méi)講一個(gè)重要的配置就是activeProfiles。
當(dāng)我配置了各種,搗騰了半天,idea里面死活加載不進(jìn)去我配置的倉(cāng)庫(kù)信息。
最后配置好activeProfiles就行了,這個(gè)基本99%的文章都沒(méi)講過(guò)要配置,自己不仔細(xì)去看文檔就會(huì)掉入陷阱。
activeProfiles 下面配置的是要激活的profile。
<activeProfiles> <activeProfile>profileid</activeProfile> </activeProfiles> maven settings.xml 配置
配置的profile
<profile> <id>profileid</id> <repositories><repository><id>snapshots</id><name>snapshots</name><url>http://xxx.xxx.xx.xx:8081/nexus/content/repositories/snapshots/</url></repository> </repositories></profile>
使用的是內(nèi)部搭建的私有倉(cāng)庫(kù)。
鏡像和倉(cāng)庫(kù)的關(guān)系<mirror><id>aliyunmaven</id><mirrorOf>central</mirrorOf><name>aliyun maven</name><url>https://maven.aliyun.com/repository/public</url></mirror>
鏡像:mirror相當(dāng)于一個(gè)攔截器,它會(huì)攔截maven對(duì)remote repository的相關(guān)請(qǐng)求,把請(qǐng)求里的remote repository地址,重定向到mirror里配置的地址。
攔截規(guī)則:mirrorOf指定的是哪個(gè)就攔截哪個(gè),central就會(huì)攔截中央倉(cāng)庫(kù)的請(qǐng)求,mirrorOf里面的值是repository的id值。比如我把central換成上面我私有倉(cāng)庫(kù)id的snapshots,那么私有倉(cāng)庫(kù)的請(qǐng)求會(huì)被轉(zhuǎn)到鏡像,當(dāng)然我們并不需要這樣。
倉(cāng)庫(kù):倉(cāng)庫(kù)是項(xiàng)目中依賴的第三方庫(kù),這個(gè)庫(kù)所在的位置叫做倉(cāng)庫(kù)。
所以并不是倉(cāng)庫(kù)和鏡像都要配置,許多文章也沒(méi)意識(shí)到這點(diǎn),如果我只用內(nèi)部搭建的私有倉(cāng)庫(kù)根本不需要去配什么鏡像。
idea 配置mavenfile->settings
配置好后刷新下重新加載,下載maven依賴
如果不好使,關(guān)掉idea再重開(kāi),idea會(huì)抽風(fēng)
以上就是IDEA設(shè)置maven修改settings.xml配置文件無(wú)法加載倉(cāng)庫(kù)的解決方案的詳細(xì)內(nèi)容,更多關(guān)于IDEA 無(wú)法加載倉(cāng)庫(kù)的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
