idea新建springboot項目pom文件報錯問題及解決
idea新建springboot項目pom文件報錯
之前也有過類似的情況,只不過都是把spring-boot-starter-parent版本號改成本地倉庫已經(jīng)有的,然后繼續(xù)開發(fā)。今天想寫個demo,就新建了一個,然后版本號不一致,就一直報錯,所以找了一天問題,才解決。
太可怕了
新建springboot項目的問題
使用idea,一路next,到最后生成項目
然后pom文件報錯
我特意換了一個全新的maven,發(fā)現(xiàn)是因為jar拉不下來,就配置了國內(nèi)鏡像
找到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>
然后發(fā)現(xiàn)還是有點問題,有些拉不下來。
繼續(xù)設(shè)置idea,打開設(shè)置,搜索maven
將上面的勾打上
然后在VM Options下面輸入
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
然后點擊最右面maven,重新安裝一下
(拉完jar之后再把勾去掉,還原)
此時已經(jīng)解決了我所有報錯的問題,然后啟動項目是啟動不起來的,因為沒有web
繼續(xù)在pom加入spring-boot-starter-web
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
啟動類中加入hello代碼校驗
啟動,瀏覽器輸入http://localhost:8080/hello
哎。真菜~
創(chuàng)建Springboot之后pom.xml文件報錯解決
記錄創(chuàng)建項目遇到的一個問題(Maven相關(guān))
通過IDEA 創(chuàng)建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>
我自己在網(wǎng)上查到解決方法有兩個:
- 鼠標(biāo)右鍵----Maven----Reload Project
- 通過右側(cè)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相對應(yīng)的版本號。我上面用的是2.4.4,這里我也就嘗試了一下2.4.4,結(jié)果真的好了
如果報錯還是沒解決的話也可以嘗試 reload project 或者 重啟idea
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
java Map轉(zhuǎn)Object與Object轉(zhuǎn)Map實現(xiàn)代碼
這篇文章主要介紹了 java Map轉(zhuǎn)Object與Object轉(zhuǎn)Map實現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-02-02Spring Security中successHandler和failureHandler使用方式
這篇文章主要介紹了Spring Security中successHandler和failureHandler使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-08-08解決IDEA克隆代碼后在右下角沒有g(shù)it分支的問題
這篇文章主要介紹了解決IDEA克隆代碼后在右下角沒有g(shù)it分支的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02java計算自然數(shù)中的水仙花數(shù)的方法分享
這篇文章主要介紹了java計算自然數(shù)中的水仙花數(shù)的方法,需要的朋友可以參考下2014-03-03java8 LocalDate LocalDateTime等時間類用法實例分析
這篇文章主要介紹了java8 LocalDate LocalDateTime等時間類用法,結(jié)合具體實例形式分析了LocalDate、LocalTime、LocalDateTime等日期時間相關(guān)類的功能與具體使用技巧,需要的朋友可以參考下2017-04-04