Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Refresh single configuration properties bean #2437

Conversation

DanielLiu1123
Copy link
Collaborator

@DanielLiu1123 DanielLiu1123 commented Mar 6, 2022

spring cloud 目前的刷新策略是全量刷新 ConfigurationPropertiesBean, 并且暂时没有支持刷新单个 ConfigurationPropertiesBean 的打算 (spring-cloud/spring-cloud-commons#1061), 因此选择自行实现。
如果配置修改频率很高,那么可以开启此功能。

Spring Cloud's current refresh strategy is refreshing all ConfigurationPropertiesBeans, and temporarily not support refreshing a single ConfigurationPropertiesBean (spring-cloud/spring-cloud-commons#1061), so choose self-realization.
If the configuration modification is very frequently, this function can be turned on.

How to use it

spring.cloud.nacos.config.refresh-behavior=specific_bean to enable, default value is all_beans.

…configuration_properties

# Conflicts:
#	spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/NacosConfigAutoConfiguration.java
@DanielLiu1123 DanielLiu1123 requested a review from zkzlx March 6, 2022 09:42
…configuration_properties

# Conflicts:
#	spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@DeBruyne2020
Copy link

DeBruyne2020 commented Jun 8, 2022

@DanielLiu1123 @steverao
大佬们 请教下哈,您平时在2021.x这个分支里开发,平时是对这个项目执行maven clean install, 然后在别的项目的pom里直接加dependency:
image

就能引到这个包,直接就能用了?,还是要执行maven clean deploy啊?

我执行编译2021.x这个分支(maven clean install), 编译是成功的,但是,在其他项目里(比如A项目)引这个dependency,然后编译A项目,一直报
Could not transfer artifact com.alibaba.cloud:spring-cloud-alibaba-starters:pom:${revision} from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/):

Illegal character in path at index 109: https://maven.aliyun.com/nexus/content/repositories/central/com/alibaba/cloud/spring-cloud-alibaba-starters/${revision}/spring-cloud-alibaba-starters-${revision}.pom ->

请教大佬们您遇到过这个情况么?

@steverao
Copy link
Collaborator

steverao commented Jun 8, 2022

@DanielLiu1123 @steverao 大佬们 请教下哈,您平时在2021.x这个分支里开发,平时是对这个项目执行maven clean install, 然后在别的项目的pom里直接加dependency: image

就能引到这个包,直接就能用了?,还是要执行maven clean deploy啊?

我执行编译2021.x这个分支(maven clean install), 编译是成功的,但是,在其他项目里(比如A项目)引这个dependency,然后编译A项目,一直报 Could not transfer artifact com.alibaba.cloud:spring-cloud-alibaba-starters:pom:${revision} from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/):

Illegal character in path at index 109: https://maven.aliyun.com/nexus/content/repositories/central/com/alibaba/cloud/spring-cloud-alibaba-starters/${revision}/spring-cloud-alibaba-starters-${revision}.pom ->

请教大佬们您遇到过这个情况么?

是的,平时开发直接本地执行mvn clean install,就可以把依赖发到本地仓库,然后本地别的项目可以直接引用。如果非本地的项目是没办法引用本地仓库的依赖的,你的报错显示是从阿里云的仓库去获取这个SNAPSHOT依赖,你是没办法将本地版本发送到阿里云镜像仓库的(需要验证,这个不能随便发的),所以别的项目直接去下载是下载不到的。

@DeBruyne2020
Copy link

DeBruyne2020 commented Jun 9, 2022

@DanielLiu1123 @steverao 大佬们 请教下哈,您平时在2021.x这个分支里开发,平时是对这个项目执行maven clean install, 然后在别的项目的pom里直接加dependency: image
就能引到这个包,直接就能用了?,还是要执行maven clean deploy啊?
我执行编译2021.x这个分支(maven clean install), 编译是成功的,但是,在其他项目里(比如A项目)引这个dependency,然后编译A项目,一直报 Could not transfer artifact com.alibaba.cloud:spring-cloud-alibaba-starters:pom:${revision} from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/):
Illegal character in path at index 109: https://maven.aliyun.com/nexus/content/repositories/central/com/alibaba/cloud/spring-cloud-alibaba-starters/${revision}/spring-cloud-alibaba-starters-${revision}.pom ->
请教大佬们您遇到过这个情况么?

是的,平时开发直接本地执行mvn clean install,就可以把依赖发到本地仓库,然后本地别的项目可以直接引用。如果非本地的项目是没办法引用本地仓库的依赖的,你的报错显示是从阿里云的仓库去获取这个SNAPSHOT依赖,你是没办法将本地版本发送到阿里云镜像仓库的(需要验证,这个不能随便发的),所以别的项目直接去下载是下载不到的。

@steverao
收到 感谢大佬🙏

大佬 ,再请教下,您遇到过这种情况么, 就是SCA源码编译(maven clean install)都是成功,如下图:
image

本地仓库里显示也有了这个jar, 如下图:
image

然后本地的其他项目的pom里引spring-cloud-starter-alibaba-nacos-config依赖(用的都是同一个repository),如下图:
image

但是死活就是爆红显示没引到
image

大佬您知道可能是什么原因么?

@DeBruyne2020
Copy link

@DanielLiu1123 @steverao 大佬们 请教下哈,您平时在2021.x这个分支里开发,平时是对这个项目执行maven clean install, 然后在别的项目的pom里直接加dependency: image
就能引到这个包,直接就能用了?,还是要执行maven clean deploy啊?
我执行编译2021.x这个分支(maven clean install), 编译是成功的,但是,在其他项目里(比如A项目)引这个dependency,然后编译A项目,一直报 Could not transfer artifact com.alibaba.cloud:spring-cloud-alibaba-starters:pom:${revision} from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/):
Illegal character in path at index 109: https://maven.aliyun.com/nexus/content/repositories/central/com/alibaba/cloud/spring-cloud-alibaba-starters/${revision}/spring-cloud-alibaba-starters-${revision}.pom ->
请教大佬们您遇到过这个情况么?

是的,平时开发直接本地执行mvn clean install,就可以把依赖发到本地仓库,然后本地别的项目可以直接引用。如果非本地的项目是没办法引用本地仓库的依赖的,你的报错显示是从阿里云的仓库去获取这个SNAPSHOT依赖,你是没办法将本地版本发送到阿里云镜像仓库的(需要验证,这个不能随便发的),所以别的项目直接去下载是下载不到的。

@steverao
大佬 ,您好,我大概找到原因了, 我对整个项目执行maven clean install, 显示是success的
image

但是去本地repository里面看打的jar包 反编译里面看pom, revision没有转化成实际的版本号
image

应该就是这个原因导致的本地其他项目引不成功,想请问大佬,您知道怎么才能打包把revision
打成转化好的具体的version么?

@steverao
Copy link
Collaborator

steverao commented Jun 13, 2022

try it by below way:

</dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
</dependencies>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
</dependencyManagement>

@DanielLiu1123 DanielLiu1123 deleted the refresh_specific_configuration_properties branch June 19, 2022 18:28
@steverao steverao added this to the 2021.0.4.0 milestone Aug 13, 2023
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.

3 participants