好问题这是因为mybatis-plus-boot-starter本身并不直接依赖mybatis-spring-boot-starter它内部已经内联了 MyBatis 相关的核心依赖。让我解释一下为什么需要显式引入它MyBatis-Plus 3.4.2 的依赖结构mybatis-plus-boot-starter:3.4.2的依赖树大致是这样的textmybatis-plus-boot-starter:3.4.2 ├── mybatis-plus:3.4.2 │ ├── mybatis-plus-extension:3.4.2 │ └── mybatis:3.5.6 ├── mybatis-spring-boot-starter:2.1.4 ← 它本身也依赖了这个 │ ├── spring-boot-starter:2.3.2.RELEASE (被排除后需要自己提供) │ ├── spring-boot-starter-jdbc:2.3.2.RELEASE │ └── mybatis-spring:2.0.6 └── spring-boot-starter:2.3.2.RELEASE为什么排除后需要显式引入当你对mybatis-plus-boot-starter排除了spring-boot-starter、spring-boot-autoconfigure等依赖后mybatis-spring-boot-starter中的 Spring Boot 相关依赖也被排除了因为它是传递依赖。但mybatis-spring-boot-starter本身需要这些 Spring Boot 依赖才能正常工作它提供了MybatisAutoConfiguration等自动配置类。所以你需要显式引入mybatis-spring-boot-starter并且指定一个与你的 Spring Boot 版本兼容的版本2.1.4以确保它依赖的spring-boot-starter等包由你项目的父 POM2.3.12统一管理而不是被 MyBatis-Plus 的传递依赖带成 2.3.2。不显式引入会怎样如果你排除了 MyBatis-Plus 的 Spring Boot 依赖但没有显式引入mybatis-spring-boot-starter那么你的项目中可能完全没有mybatis-spring-boot-starter的自动配置类。或者mybatis-spring-boot-starter的版本被传递依赖带成了一个不兼容的版本比如 2.2.0它依赖 Spring Boot 2.5.x。这会导致 MyBatis-Plus 无法正常初始化启动时报NoSuchBeanDefinitionException或MybatisAutoConfiguration相关错误。另一种方式只排除 Spring Boot保留 mybatis-spring-boot-starter如果你不想显式引入mybatis-spring-boot-starter可以更精细地排除只排除它带来的 Spring Boot 依赖但保留mybatis-spring-boot-starter本身xmldependency groupIdcom.baomidou/groupId artifactIdmybatis-plus-boot-starter/artifactId version3.4.2/version exclusions !-- 排除 mybatis-plus-boot-starter 直接依赖的 spring-boot-starter -- exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter/artifactId /exclusion exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-autoconfigure/artifactId /exclusion !-- 排除 mybatis-spring-boot-starter 传递来的 spring-boot-starter-jdbc -- exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jdbc/artifactId /exclusion !-- 但保留 mybatis-spring-boot-starter 本身不排除 -- /exclusions /dependency这样mybatis-spring-boot-starter:2.1.4仍然会被引入但它依赖的spring-boot-starter等包会被你项目的父 POM2.3.12覆盖掉因为父 POM 的dependencyManagement优先级更高。这种方式不需要显式引入mybatis-spring-boot-starter但需要确保父 POM 的dependencyManagement中锁定了所有 Spring Boot 相关版本。总结方式优点缺点显式引入mybatis-spring-boot-starter:2.1.4明确可控版本清晰多写一行依赖不显式引入只排除 Spring Boot 包简洁依赖父 POM 的dependencyManagement正确锁定版本两种方式都可以但从清晰可维护的角度推荐显式引入mybatis-spring-boot-starter因为它明确告诉其他开发者你使用的版本是兼容的。