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 pause
3.刪除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 pause
4. 刪除_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)文章
淺談Spring中@NotEmpty、@NotBlank、@NotNull區(qū)別
本文主要介紹了淺談Spring中@NotEmpty、@NotBlank、@NotNull區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02Maven工程搭建spring boot+spring mvc+JPA的示例
本篇文章主要介紹了Maven工程搭建spring boot+spring mvc+JPA的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01Java基礎(chǔ)總結(jié)之Thymeleaf詳解
Thymeleaf是一種現(xiàn)代的基于服務(wù)器端的Java模板引擎技術(shù),也是一個優(yōu)秀的面向Java的XML、XHTML、HTML5頁面模板,它具有豐富的標(biāo)簽語言、函數(shù)和表達(dá)式,在使用Spring Boot框架進(jìn)行頁面設(shè)計時,一般會選擇Thymeleaf模板,需要的朋友可以參考下2021-05-05解決mybatis三表連接查詢數(shù)據(jù)重復(fù)的問題
這篇文章主要介紹了解決mybatis三表連接查詢數(shù)據(jù)重復(fù)的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01Spring中@Autowired注解作用在方法上和屬性上說明
這篇文章主要介紹了Spring中@Autowired注解作用在方法上和屬性上說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11MyBatisPlus查詢報錯Unknow?column?‘id‘?in?‘field?list‘解決分析
這篇文章主要為大家介紹了MyBatisPlus查詢報錯Unknow?column?‘id‘?in?‘field?list‘解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09Java使用iTextPDF生成PDF文件的實現(xiàn)方法
這篇文章主要介紹了Java使用iTextPDF生成PDF文件的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02