1. 程式人生 > >Maven建立SpringBoot parent標籤報錯或者頭資訊報錯解決

Maven建立SpringBoot parent標籤報錯或者頭資訊報錯解決

注:為了演示錯誤所以上下文出現的spring-boot-starter-parent版本不一致

報錯資訊1:

  parent標籤報錯:

  Project build error: Non-resolvable parent POM: Failure to find org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM
解決方式:

  是因為中央倉庫找不到父類POM路徑的問題,百度到的解決方案是:

  將中央倉庫設定為阿里雲-清空本地倉庫-Update project或者是設定<relativePath>../../pom.xml</relativePath>

  但是發現設定後還是無效,本地倉庫下載下來的檔案是:spring-boot-starter-parent-1.6.4.RELEASE.pom.lastUpdated(錯誤的如圖:)

 

 

  最後發現無需修改任何東西,一直刪除本地倉庫的殘留錯誤的檔案-》UpdatePoject即可(看運氣,可能是因為你的網路不好或者是因為各種外在原因)直到在本地倉庫如圖的檔案即代表第一個錯誤解決(接下來就會出現錯誤資訊2):

 

報錯資訊2:


pom檔案頭資訊報錯

org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject,
 org.apache.maven.archiver.MavenArchiveConfiguration)
(這個錯最坑,會導致所有正常的maven專案報錯,導致我重灌了Myeclipse)

解決方式:
 
百度到的解決方式是:

  百度說,原因是自己的Maven配置檔案不是最新的,按照步驟操作下來後導致所有maven錯誤...由於是新手的問題,重灌了MyEclipse

解決步驟:

1.將自己的spring-boot-starter-parent版本由2.0.0.RELEASE降至1.5.9RELEASE(注 意在第一步的時候從中央倉庫下載的版本就得是1.5.9RELEASE)然後parent標籤配置如下:

<parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>1.5.9.RELEASE</version>
  </parent>


2.將pom中的dependencies裡這樣配置:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

一定要新增第二個!不然會報別的錯

 

總結:將正確的檔案下載到本地倉庫->降低版本->新增spring-boot-starter-test

百度出來的解決方案不一定全部適合自己,不要一昧的按步驟操作,要理解這麼做是為什麼
如果還是解決不了+我QQ:812130200 我來遠端給你解決
如果覺得解決方法有用請評論下有用哦!謝謝