1. 查看项目的启动类
Spring Boot: 通常有一个主类,包含 @SpringBootApplication 注解,并且有一个 main 方法来启动应用程序。
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Spring MVC: 通常没有这样的启动类,项目的启动依赖于外部Web容器(如Tomcat)的配置。
2. 查看 pom.xml 或 build.gradle 文件
Spring Boot: 通常会有 spring-boot-starter 相关的依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
Spring MVC: 依赖项通常是 spring-webmvc,而不是 spring-boot-starter。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
3. 查看配置文件
Spring Boot: 通常使用 application.properties 或 application.yml 文件来配置应用程序。
server.port=8080
spring.datasource.url=jdbc:mysql://localhost:3306/db
Spring MVC: 通常使用 web.xml 或 applicationContext.xml 文件来配置应用程序。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
4. 查看项目结构
Spring Boot: 项目结构通常比较简洁,主要包含 src/main/java 和 src/main/resources 目录。

Spring MVC: 项目结构通常包含 src/main/webapp 目录,并且有 WEB-INF 文件夹。

5.查看依赖管理
Spring Boot: 使用 spring-boot-starter-parent 作为父项目。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
</parent>
Spring MVC: 通常使用 spring-framework-bom 或者没有特定的父项目。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
总结
通过查看项目的启动类、依赖配置、配置文件、项目结构和依赖管理,可以快速判断一个项目是Spring MVC框架还是Spring Boot框架。Spring Boot项目通常有一个带有 @SpringBootApplication 注解的启动类,使用 spring-boot-starter 相关的依赖,并且配置文件是 application.properties 或 application.yml。Spring MVC项目通常依赖于外部Web容器,使用 spring-webmvc 依赖,并且配置文件是 web.xml 或 applicationContext.xml。



















