• 引言
  • 使用Spring Innitializer创建SpringBoot项目
  • 解决方案

引言

笔者使用的IDEA版本为2020.2.4, 在使用Spring Innitializer创建SpringBoot项目后, SpringBoot项目无法被识别IDEA正常识别, 本文将来解决这个问题.

使用Spring Innitializer创建SpringBoot项目

首先通过4张图片, 来演示下笔者是如何通过Spring Innitializer来创建SpringBoot项目的:

创建完项目后, 如下图所示, 发现IDEA无法识别java文件

查看project struct, 也发现无法识别此项目为SpringBoot项目

解决方案

造成这个问题的原因, 是因为默认的maven版本(3.8.6)过高导致的, 降低maven的版本到3.5.4即可

修改项目目录/.mvn/wrapper/maven-wrapper.properties为下列内容(只改了第一行maven的版本号)

distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zipwrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

修改后, 重启下IDEA, IDEA就能够识别了