1.查看项目依赖
查看spring-boot-starter-parent 或 spring-boot-starter-web 在pom文件中是不是存在的
比如:
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
在上述示例代码中,可以看到该项目的父依赖为 spring-boot-starter-parent,并且项目依赖了 spring-boot-starter-web,这表明该项目是一个基于 Spring Boot 框架构建的 Web 项目。
2.查看启动类项
在项目的源代码中是不是可以找到如下代码:
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
上述方使用注解标注了MyApplication类,并在main方法中调用了SpringApplication.run方法启动程序,这是Springboot的启动姿势,如果看到该调用方法也表明是一个springboot项目
如果没有达到上面的两个要求,可能就是Spring项目,因为一个springboot项目应该包含上述两个要求。