Skip to content

Comments

feat: spring-cloud-starter-bootstrap is no longer supported#4260

Open
xuxiaowei-com-cn wants to merge 7 commits intoalibaba:2025.1.xfrom
xuxiaowei-com-cn:xuxiaowei/2025.1.x-disable-bootstrap
Open

feat: spring-cloud-starter-bootstrap is no longer supported#4260
xuxiaowei-com-cn wants to merge 7 commits intoalibaba:2025.1.xfrom
xuxiaowei-com-cn:xuxiaowei/2025.1.x-disable-bootstrap

Conversation

@xuxiaowei-com-cn
Copy link
Contributor

When org.springframework.cloud:spring-cloud-starter-bootstrap is present in the classpath, the application will fail to start with a descriptive error message. This is to enforce the new configuration loading mechanism and avoid conflicts.

Reference: #4259

Describe what this PR does / why we need it

Does this pull request fix one issue?

Describe how you did it

Describe how to verify it

Special notes for reviews

When `org.springframework.cloud:spring-cloud-starter-bootstrap` is present in the classpath, the application will fail to start with a descriptive error message.
This is to enforce the new configuration loading mechanism and avoid conflicts.

Reference: alibaba#4259
@xuxiaowei-com-cn
Copy link
Contributor Author

当且仅当存在 org.springframework.cloud.bootstrap.marker.Marker 时,可以判断出使用了 org.springframework.cloud:spring-cloud-starter-bootstrap

https://github.com/spring-cloud/spring-cloud-commons/blob/main/spring-cloud-starter-bootstrap/src/main/java/org/springframework/cloud/bootstrap/marker/Marker.java

image

@uuuyuqi
Copy link
Collaborator

uuuyuqi commented Feb 11, 2026

Honestly, throwing an exception to directly block the application startup might not be the best approach here. It feels a bit too aggressive. In many users' projects, dependency trees can be quite messy (often unintentionally😥)

Instead, we could print an ERROR log during the initialization phase or when components are loading. We can warn the user that spring-cloud-starter-bootstrap has been detected, which implies that nacos config might not work as expected.

- Add `spring.cloud.nacos.config.enable-check-bootstrap` property (default true) to allow users to disable the bootstrap check.
- Rename `checkBootstrapConfiguration` bean to `checkBootstrap` and add conditional property check.
@xuxiaowei-com-cn
Copy link
Contributor Author

The exception has been modified to a warning log.

@uuuyuqi

@xuxiaowei-com-cn xuxiaowei-com-cn changed the title feat: Prohibit usage of spring-cloud-starter-bootstrap feat: spring-cloud-starter-bootstrap is no longer supported Feb 14, 2026
/**
* whether to check if the bootstrap configuration is enabled, default is true.
*/
private boolean enableCheckBootstrap = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该没有实际使用到,得考虑一下这个属性是否有必要

Copy link
Contributor Author

@xuxiaowei-com-cn xuxiaowei-com-cn Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

虽然该属性没有实际使用到,但是有利于使用者发现此功能,比如:代码自动提示、yaml 代码不会出现警告等等

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个功能默认开,应该无需开发者额外关注和特意去关闭,理论上确实用不到的哈,我的建议还是删除~

@ConditionalOnProperty(name = "spring.cloud.nacos.config.enable-check-bootstrap", matchIfMissing = true)
@ConditionalOnClass(name = "org.springframework.cloud.bootstrap.marker.Marker")
public Object checkBootstrapConfiguration() {
log.warn("Including 'org.springframework.cloud:spring-cloud-starter-bootstrap' is prohibited. "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果考虑 warn 级别日志更合适的话,这里不建议说是 【prohibited】,改为 【not work properly】可能好一些

public Object checkBootstrapConfiguration() {
log.warn("Including 'org.springframework.cloud:spring-cloud-starter-bootstrap' is prohibited. "
+ "For details, please refer to: https://github.com/alibaba/spring-cloud-alibaba/issues/4259");
return null;
Copy link
Collaborator

@uuuyuqi uuuyuqi Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null 看起来怪怪的,也许你觉得这个不重要,因为主要想使用@ConditionalOnClass(name = "org.springframework.cloud.bootstrap.marker.Marker") 这个扩展点来打印一条日志。但是 @Bean 注解里面 return null 还是不太妥当,这是一种反模式。可能得换一种方式来实现这个日志打印。AI 工具给的建议是直接使用内部配置类,这确实也挺简单的,你可以看一下哈:

@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(name = "spring.cloud.nacos.config.enable-check-bootstrap", matchIfMissing = true)
@ConditionalOnClass(name = "org.springframework.cloud.bootstrap.marker.Marker")
static class BootstrapDetectionConfiguration {
    BootstrapDetectionConfiguration() {
        LoggerFactory.getLogger(BootstrapDetectionConfiguration.class)
            .warn("Detected 'spring-cloud-starter-bootstrap' on the classpath...");
    }
}

@xuxiaowei-com-cn
Copy link
Contributor Author

已处理

static class BootstrapDetectionConfiguration {
BootstrapDetectionConfiguration() {
LoggerFactory.getLogger(BootstrapDetectionConfiguration.class)
.warn("Including 'org.springframework.cloud:spring-cloud-starter-bootstrap' not work properly. "
Copy link
Collaborator

@uuuyuqi uuuyuqi Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里感觉语法有问题,可以考虑改为:Including 'org.springframework.cloud:spring-cloud-starter-bootstrap' will prevent Nacos Config from working properly. Please remove this dependency. For details...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants