首頁  >  文章  >  Java  >  idea新建springboot專案pom檔案報錯如何解決

idea新建springboot專案pom檔案報錯如何解決

王林
王林轉載
2023-05-14 14:28:121983瀏覽

    新建springboot專案的問題

    使用idea,一路next,到最後產生專案

    然後pom檔案報錯

    #我刻意換了一個全新的maven,發現是因為jar拉不下來,就配置了國內鏡像

    找到maven ,conf 打開settings.xml。在mirrors裡面寫入

    <!-- 阿里云镜像 -->
    	<mirror>
    		<id>alimaven</id>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    		<mirrorOf>central</mirrorOf>
    	</mirror>
    	<mirror>
    		<id>central</id>
    		<name>Maven Repository Switchboard</name>
    		<url>http://repo1.maven.org/maven2/</url>
    		<mirrorOf>central</mirrorOf></mirror>
    	<mirror>
    		<id>repo2</id>
    		<mirrorOf>central</mirrorOf>
    		<name>Human Readable Name for this Mirror.</name>
    		<url>http://repo2.maven.org/maven2/</url>
    	</mirror>
    	
    	<mirror>
    		<id>ibiblio</id>
    		<mirrorOf>central</mirrorOf>
    		<name>Human Readable Name for this Mirror.</name>
    		<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
    		</mirror>
    <!-- 中央仓库在中国的镜像 -->
    	<mirror>
    		<id>maven.net.cn</id>
    		<name>oneof the central mirrors in china</name>
    		<url>http://maven.net.cn/content/groups/public/</url>
    		<mirrorOf>central</mirrorOf>
    	</mirror>

    然後發現還是有點問題,有些拉不下來。

    繼續設定idea,開啟設置,搜尋maven

    idea新建springboot專案pom檔案報錯如何解決

    #將上面的勾選上

    然後在VM Options下面輸入

    -Dmaven.wagon.http.ssl.insecure=true
    -Dmaven.wagon.http.ssl.allowall=true
    -Dmaven.wagon.http.ssl.ignore.validity.dates=true

    然後點選最右邊maven,重新安裝一下

    (拉完jar之後再把勾去掉,還原)

    idea新建springboot專案pom檔案報錯如何解決

    此時已經解決了我所有報錯的問題,然後啟動專案是啟動不起來的,因為沒有web

    繼續在pom加入spring-boot-starter-web

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

    啟動類別中加入hello程式碼校驗

    idea新建springboot專案pom檔案報錯如何解決

    啟動,瀏覽器輸入http://localhost:8080/hello

    idea新建springboot專案pom檔案報錯如何解決

    建立Springboot之後pom. xml檔案報錯解決

    記錄建立專案遇到的一個問題(Maven相關)

    透過IDEA 建立Springboot專案之後,pom.xml 在以下程式碼中報錯誤

    #提示spring-boot-starter-parent not found

    <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>2.4.4</version>
       <relativePath/> 
    </parent>

    #我自己在網路上查到解決方法有兩個:

    • 滑鼠右鍵----Maven----Reload Project

    • 透過右側Maven選單列----Reload Project

    ################################################################################################################################################################## #其實就是一個。不管怎麼reload,或是download source都沒用(還試過修改版本號),然後我就重啟,果然重啟就好了######遇到的另一個問題,也是提醒我spring-boot- maven-plugin not found###
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    ######解決方法:##########新增與上面spring-boot-starter-parent相對應的版本號碼。我上面用的是2.4.4,這裡我也就試了一下2.4.4,結果真的好了######如果報錯還是沒解決的話也可以嘗試 reload project 或 重啟idea ####

    以上是idea新建springboot專案pom檔案報錯如何解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!

    陳述:
    本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除