spring-cloud-alibaba icon indicating copy to clipboard operation
spring-cloud-alibaba copied to clipboard

spring.factories文件里面指定的EnvironmentPostProcessor错误

Open baifachuan opened this issue 4 weeks ago • 5 comments

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。另外请按照如下要求提交相关信息节省社区维护同学的理解成本,否则该讨论极有可能直接被忽视或关闭。 We recommend using English. If you are non-native English speaker, you can use the translation software. We recommend using English. If you are non-native English speaker, you can use the translation software. In addition, please submit relevant information according to the following requirements to save the understanding cost of community maintenances, otherwise the discussion is very likely to be ignored or closed directly.

Image

这里没有更新,实际上是: org.springframework.boot.EnvironmentPostProcessor,现在启动就会报错:

Caused by: java.lang.IllegalArgumentException: Class [com.alibaba.cloud.nacos.configdata.NacosConfigDataMissingEnvironmentPostProcessor] is not assignable to factory type [org.springframework.boot.env.EnvironmentPostProcessor]
	at org.springframework.util.Assert.isTrue(Assert.java:136)
	at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:219)
	... 40 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:49517', transport: 'socket'

Which Component eg. Nacos Discovery, Sentinel

Describe the bug A clear and concise description of what the bug is.

Simplest demo The URL of the simplest demo to reproduce the problem.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here. e.g. MacOS 、Java8 、 Version 0.2.1.RELEASE

baifachuan avatar Nov 27 '25 16:11 baifachuan

这个 PR 已修正,待合并:https://github.com/alibaba/spring-cloud-alibaba/pull/4068

xuxiaowei-com-cn avatar Nov 27 '25 16:11 xuxiaowei-com-cn

这个问题应该会在下个版本解决吧?问题是,下个版本什么时候发布?

shaobin0613 avatar Nov 30 '25 10:11 shaobin0613

@shaobin0613 https://github.com/alibaba/spring-cloud-alibaba/pull/4068#issuecomment-3584648316

xuxiaowei-com-cn avatar Nov 30 '25 11:11 xuxiaowei-com-cn

Image

2025.1.x 修正提交 https://github.com/xuxiaowei-com-cn/spring-cloud-alibaba/commit/cb170e19cc742a2812384afa15237fbd0b41c77f#diff-83052a156feae0470f97df6ca092cc372bfae3a88bd6911cb57325f552fe5c64L5

xuxiaowei-com-cn avatar Dec 05 '25 06:12 xuxiaowei-com-cn

spring.factories 是 Spring Boot 2.X 的方式,在 Spring Boot 3 中只能算作兼容或者过时的方式。

spring.factories 文件存在的价值,一方面是通用组件为了兼容 Spring Boot 2.X,另一方面就是为了支持 Bootstrap 模式。

但是 Spring Cloud Alibaba 自 2023.0.1.3 版本之后已经不推荐 Spring Cloud Bootstrap 方式, 社区后续也会考虑删除。而且 Spring Cloud 2025.1.0,基于 Spring Boot 4.X 与 Spring Boot 3.X 都无法兼容,就更本没有必要考虑与 Spring Boot 2.X 兼容的问题了。所以可以完全不需要 spring.factories 文件了。

因此,个人觉得 spring.factories 文件可以在删除 Bootstrap 方式 的同时同步删掉。其实 Spring Cloud Alibaba 2025.1.0.0 就可以做这个事情。

herodotus-ecosystem avatar Dec 09 '25 15:12 herodotus-ecosystem