idea新建springboot项目pom文件报错

前言

之前也有过类似的情况,只不过都是把spring-boot-starter-parent版本号改成本地仓库已经有的,然后继续开发。今天想写个demo,就新建了一个,然后版本号不一致,就一直报错,所以找了一天问题,才解决。太可怕了

新建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

将上面的勾打上
然后在VM Options下面输入

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

然后点击最右面maven,重新安装一下
(拉完jar之后再把勾去掉,还原)

此时已经解决了我所有报错的问题,然后启动项目是启动不起来的,因为没有web
继续在pom加入spring-boot-starter-web

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

启动类中加入hello代码校验

启动,浏览器输入http://localhost:8080/hello

哎。真tm菜

发布了70 篇原创文章 · 获赞 30 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/gfl1427097103/article/details/104840380