添加spring-cloud-starter-sleuth后触发Pointcut must not be null异常求助
解决Spring Cloud Sleuth添加后启动报错"Pointcut must not be null"的问题
问题分析
你遇到的Pointcut must not be null错误,本质是AspectJ切面相关依赖冲突。结合你的依赖配置来看,核心原因是重复引入了Spring Cloud Sleuth的核心组件:
- 主项目已引入
spring-cloud-starter-sleuth,该starter默认包含spring-cloud-sleuth-instrumentation模块 - 子项目
client又单独引入了spring-cloud-sleuth-instrumentation,导致同一模块重复加载,引发切面定义冲突,最终触发Pointcut为空的异常
此外,你手动指定的jackson-module-kotlin:2.9.8版本与Spring Boot 2.6.4 BOM默认管理的Jackson版本(2.13.3)不兼容,可能加剧依赖冲突问题。
解决方案
1. 移除重复的Sleuth依赖
删除client项目中的spring-cloud-sleuth-instrumentation依赖,因为spring-cloud-starter-sleuth已自动包含该组件:
// 移除该行重复依赖 // implementation(group = "org.springframework.cloud", name = "spring-cloud-sleuth-instrumentation")
2. 统一依赖版本管理
去掉jackson-module-kotlin的手动版本号,让Spring Boot BOM自动管理兼容版本:
// 修改前 // implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin", version = "2.9.8") // 修改后 implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin")
3. 验证依赖树(可选)
使用Gradle命令检查依赖冲突,确保所有Sleuth相关依赖版本一致:
./gradlew dependencies --configuration compileClasspath | grep sleuth
输出中所有Sleuth组件的版本应统一为Spring Cloud 2021.0.1 BOM指定的版本(3.1.1)。
修改后的client项目依赖示例
implementation(platform("org.springframework.boot:spring-boot-dependencies:2.6.4")) implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2021.0.1")) implementation(group = "org.springframework.boot", name = "spring-boot-starter-webflux") testImplementation(group = "org.springframework.boot", name = "spring-boot-starter-actuator") implementation(group = "org.springframework.security", name = "spring-security-oauth2-client") implementation(group = "org.springframework.security", name = "spring-security-oauth2-jose") implementation(group = "com.fasterxml.jackson.module", name = "jackson-module-kotlin") implementation(group = "io.github.microutils", name = "kotlin-logging", version = "2.1.23") implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.6.4") implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactive", version = "1.6.4") implementation(group = "io.github.resilience4j", name = "resilience4j-circuitbreaker", version = "1.7.0") implementation(group = "io.github.resilience4j", name = "resilience4j-kotlin", version = "1.7.0")
内容的提问来源于stack exchange,提问作者DenisKorotchenko
相关产品推荐
相关产品推荐

