1. 程式人生 > >maven pom檔案報錯:Multiple annotations found at this line 解決方案

maven pom檔案報錯:Multiple annotations found at this line 解決方案

研究maven多模組專案時,因為家裡和公司不能同時開發,所以把家裡搭建好的專案複製到公司繼續研究,

當時家裡的電腦搭建好專案之後是沒問題的,但是複製到公司的eclipse上之後就看到pom檔案出現下面的錯誤:

Multiple annotations found at this line:
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile)
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)
    - CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be
     resolved: The repository system is offline but the artifact com.google.collections:google-collections:jar:1.0 is not available in the local repository.
    - CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be
     resolved: The repository system is offline but the artifact com.google.collections:google-collections:jar:1.0 is not available in the local repository.

網上搜羅一大堆都沒找到解決辦法,最後在一個英文文件找到了解決方案,翻譯是這樣的

這不是一個獨特的問題,偶爾發生(有時由於連線緩慢,有時由於代理伺服器現在允許下載)
你可以通過以下任何一種方式來擺脫這個問題:
1)強制更新:右鍵單擊Eclipse中的專案> Maven >更新專案在該螢幕上選擇快照/釋出的複選框強制更新
2)清除Maven快取:如果您仍然面臨問題,請轉到系統上的本地儲存庫,該庫可能存在ATC:\\\使用者\ MyUrNeNe\\M2\ReaviToRyy,並刪除.cache資料夾,然後執行步驟1。
3)如果仍然面臨問題,手動轉到ORG/Apache資料夾,刪除所有內容,然後執行步驟1。(這肯定會解決這個問題。)

我用了第三種方法,意思就是將你的maven倉庫全刪掉,重新下載一遍,使用以下流程:

1、找到你的maven倉庫包位置,刪掉repository資料夾下的所有檔案,


2、然後右擊專案->maven->update maven configuration...

offline和fore update of snapssots/Releases(強制更新)一定要勾選上,

下載完之後你會發現,問題解決了!!!

如果還不能解決,在pom檔案加個依賴:

<dependency>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-resources-plugin</artifactId>
	<version>2.4.3</version>
</dependency>
我就是 這麼解決的!