IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

使用 Spring Cloud Alibaba Nacos Config 作为配置中心

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

什么是 Nacos Config

在分布式系统中,由于服务数量巨多,为了方便服务 配置文件统一管理实时更新,所以需要分布式配置中心组件。

Spring Cloud Alibaba Nacos ConfigSpring Cloud Config 的替代方案。

Nacos Config 的存储配置功能为分布式系统中的外部化配置提供服务器端和客户端支持,可以在 Nacos 中集中管理 Spring Cloud 应用的外部属性配置。

引入依赖

pom.xml 中添加 spring-cloud-starter-alibaba-nacos-config 依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

在 Nacos 控制台中发布配置

访问 Nacos 控制台,在配置列表中新建一个配置

127_1.png

在该页面中添加项目配置信息

注:Nacos Config 中的配置内容不能带有注释,否则项目启动会失败

127_2.png

相关配置

需要在 bootstrap.properties 中优先配置 Nacos Config 客户端

spring.profiles.active=dev
spring.application.name=service-provider-config
spring.cloud.nacos.config.server-addr=192.168.127.132:8848
spring.cloud.nacos.config.file-extension=yaml

注:Spring Boot 配置文件的加载顺序,依次为 bootstrap.properties > bootstrap.yaml > application.properties > application.yaml

Application 入口类中添加注解 @RefreshScope 开启动态刷新配置功能

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;

@SpringBootApplication
@RefreshScope
public class ConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }
}

文章永久链接:https://tech.souyunku.com/?p=23941


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(65) 打赏



未经允许不得转载:搜云库技术团队 » 使用 Spring Cloud Alibaba Nacos Config 作为配置中心

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367