移除spring-statemachine-cosmos依赖后SpringBoot启动报错求助
问题与解决方案:移除Spring Statemachine Cosmos Starter后启动报错
在基于Java 11、Spring Boot 2.6.15的应用中,移除版本3.7.0的Maven依赖spring-statemachine-cosmos-spring-boot-starter后,启动应用时抛出以下错误:
java.lang.IllegalStateException: Unable to retrieve @EnableAutoConfiguration base package
已移除所有JUnit测试,但问题仍未解决。
更新信息(2023年12月19日)
Maven依赖树部分结果:
[INFO] com.wba:prt-mgr:jar:9.10-SNAPSHOT [INFO] +- com.pltfrmx:tracing-spring-boot-starter:jar:1.2.0:compile [INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.15:compile [INFO] | \- com.pltfrmx:tracing:jar:1.2.0:compile [INFO] | +- org.springframework:spring-beans:jar:5.3.27:compile [INFO] | \- io.zipkin.brave:brave:jar:5.13.9:compile [INFO] | \- io.zipkin.reporter2:zipkin-reporter-brave:jar:2.16.3:compile [INFO] +- com.pltfrmx:tracing-spring-boot-starter:jar:1.2.0:compile [INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.15:compile [INFO] | \- com.pltfrmx:tracing:jar:1.2.0:compile [INFO] | +- org.springframework:spring-beans:jar:5.3.27:compile [INFO] | \- io.zipkin.brave:brave:jar:5.13.9:compile [INFO] | \- io.zipkin.reporter2:zipkin-reporter-brave:jar:2.16.3:compile
可能的解决方法
显式指定自动配置扫描包路径
启动类上的@SpringBootApplication默认包含自动配置逻辑,若自动扫描失效,直接显式指定根包路径:@SpringBootApplication(scanBasePackages = "com.wba.prtmgr") // 替换为你的实际应用根包 public class PrtMgrApplication { public static void main(String[] args) { SpringApplication.run(PrtMgrApplication.class, args); } }也可单独添加
@EnableAutoConfiguration指定包:@EnableAutoConfiguration(basePackages = "com.wba.prtmgr") @SpringBootApplication public class PrtMgrApplication { ... }清理残留配置与依赖冲突
- 执行
mvn dependency:tree完整分析依赖,确认是否有其他依赖间接引入了spring-statemachine相关的自动配置类,导致残留逻辑扫描无效包。 - 检查
src/main/resources/META-INF/spring.factories文件,删除移除依赖后残留的org.springframework.boot.autoconfigure.EnableAutoConfiguration条目。
- 执行
清理Maven缓存与构建产物
执行mvn clean install -U,强制更新依赖并清理旧构建文件;也可手动删除本地Maven仓库中与spring-statemachine-cosmos相关的目录,确保彻底移除该依赖。检查自动配置排除项
查看启动类上的@SpringBootApplication(exclude = {...})或@EnableAutoConfiguration(exclude = {...})配置,移除不再需要的排除项,避免干扰正常的自动配置扫描。
内容的提问来源于stack exchange,提问作者user2984483
相关产品推荐
相关产品推荐

