idea?與?maven?使用過程中遇到的問題及解決方案
1. maven項目導(dǎo)入idea報ComponentLookupException異常
1.1. 問題描述
最近將IDEA 升級到 IntelliJ IDEA 2021.3.2,在將maven項目導(dǎo)入IDEA后,maven build時報如下異常:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NoSuchMethodError: org.apache.maven.model.validation.DefaultModelValidator: method <init>()V not found
at org.jetbrains.idea.maven.server.embedder.CustomModelValidator.<init>(Unknown Source)
while locating org.jetbrains.idea.maven.server.embedder.CustomModelValidator
at ClassRealm[maven.ext, parent: ClassRealm[plexus.core, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.model.validation.ModelValidator annotated with @com.google.inject.name.Named(value=ide)
1 error
role: org.apache.maven.model.validation.ModelValidator
roleHint: ide
1.2.解決方案
這個問題是IntelliJ IDEA 2021.3.2 不兼容導(dǎo)致的。 我使用的Maven版本是3.8.3, 將Maven版本降至3.8.1 或 使用IDEA Bundled(Maven3)即可解決。

2. IDEA無法加載maven本地倉庫的文件
2.1.問題描述
如果公司 Nexus私服 里面沒有對應(yīng)的依賴jar包,但本地倉庫有_remote.repositories文件,
這種情況下IDEA無法加載本地的jar包,導(dǎo)致MAVEN依賴變成紅色

_remote.repositories 內(nèi)容類似如下:

2.2.解決方案
查找并刪除所有_remote.repositories文件 clear_remote.repositories.bat
set REPOSITORY_PATH=D:\maven\repository
echo is finding all _remote.repositories file ...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*_remote.repositories*"') do (
del /s /q %%i
)
echo delete all _remote.repositories has finished
pause3.刪除maven下載失敗的jar包
3.1. 問題描述
maven針對更新失敗的依賴,在對應(yīng)的文件夾中都生成了lastUpdated后綴結(jié)尾的文件,這些文件有時會導(dǎo)致IDEA不能正常加載這些本地依賴。

3.2.解決方案
查找并刪除所有包含lastUpdated的文件 clear_lastUpdated.bat
set REPOSITORY_PATH=D:\maven\repository
echo is finding all lastUpdated file ...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
del /s /q %%i
)
echo delete all lastUpdated has finished
pause4. 刪除_maven.repositories文件
4.1.問題描述
Maven tries to update your jar from the old location (as saved in _maven.repositories) and fails. The presumtion here is that the same aftifact on a different remote repository might be different.
Maven試圖從舊位置(保存在_maven.repositories中)更新jar,但失敗了。這里的假設(shè)是,相同的aftifact 在不同的遠(yuǎn)程存儲庫上可能是不同的。
有時此文件會導(dǎo)致jar更新或加載失敗
4.2.解決方案
查找并刪除所有包含_maven.repositories的文件 clear_maven.repositories.bat
set REPOSITORY_PATH=D:\maven\repository
echo is finding all _maven.repositories file ...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*_maven.repositories*"') do (
del /s /q %%i
)
echo delete all _maven.repositories has finished
pause到此這篇關(guān)于idea 與 maven 使用過程中遇到的坑的文章就介紹到這了,更多相關(guān)idea maven使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
圖解Java?ReentrantLock公平鎖和非公平鎖的實現(xiàn)
ReentrantLock是Java并發(fā)中十分常用的一個類,具備類似synchronized鎖的作用。但是相比synchronized,?它具備更強(qiáng)的能力,同時支持公平鎖和非公平鎖。本文就來聊聊ReentrantLock公平鎖和非公平鎖的實現(xiàn),需要的可以參考一下2022-10-10
SpringCloud-Alibaba-Nacos啟動失敗解決方案
這篇文章主要介紹了SpringCloud-Alibaba-Nacos啟動失敗解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-04-04
JAVA 實現(xiàn)二叉樹(鏈?zhǔn)酱鎯Y(jié)構(gòu))
本篇文章主要介紹用JAVA 實現(xiàn)二叉樹,并提供實例.對二叉樹數(shù)據(jù)結(jié)構(gòu)很好的學(xué)習(xí)實踐,有需要的朋友可以參考下2016-07-07
JavaWeb學(xué)習(xí)筆記之Filter和Listener
這篇文章主要給大家介紹了關(guān)于JavaWeb學(xué)習(xí)筆記之Filter和Listener的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03

