Java SpringCloud Series (8) - Springboot2.1.x Integrated NACOS as Configuration Center and Dynamic Modification Configuration Center content Code Description

tags: springcloud  spring boot  nacos  Configuration Center  

Previous article We explain the basic preparation work, and how to integrate SpringBoot with Nacos as a registration center. Today we continue to play NACOS as a configuration center. This article is based on two articles. Subsequent, some pre-prepared work will not be more detailed, and the classmates who do not know can first view the following article content.
Java SpringCloud Series (6) - NACOS Single Edition / Cluster Edition and Precautions under Linux
Java SpringCloud Series (7) - SpringBoot2.1.x Integrated NACOS as a Register Correspondence Code Description

First, NACOS configuration center integration

Step 1: Add dependence

	// https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config
	implementation group: 'com.alibaba.cloud', name: 'spring-cloud-starter-alibaba-nacos-config', version: '2.1.2.RELEASE'

Step 2: Add a corresponding configuration in the bootstrap.yml configuration file, the code meaning has a correspondence in the code, please read it yourself.

# ================================= Basic configuration ======================================================================================================================================================================================================= =================================================================================================================================================================================
server:
  port: 7165
spring:
  application:
    name: beyondli-nacos-demo
  # Can use this parameter to perform environmental distinguishing (file name rules for Spring.Application.name-profiles.active.file-extension)
  #profiles:
  #  active: dev
  cloud:
    nacos:
      discovery:
        server-addr: ip:Port
      config:
        server-addr: ip:Port
        file-extension: yaml
        # Default value for default_group Use this parameter to use this parameter to distinguish (file name rules for Spring.Application.name-profiles.active.file-extension)
        group: BEYONDLI_NACOS_DEV

Step 3: Enter NACOS to create a corresponding configuration file based on the code in the code

Step 4: Writing Getting Configuration Center Value Code


Second, dynamic modification configuration center content

Step 1: Add @refreshscope on the required class

Step 2: Modify the configuration center value for testing

Step 3: Refresh the interface, return value automatic changes

All right. The above is all of our articles.

Intelligent Recommendation

SpringCloud Nacos Configuration Center

Nacos Config Center The previous article introduced the use of the configuration center in Spring Cloud, address: This section introduces the use of Nacos as a configuration center, without Github The...

SpringCloud Configuration Center NACOS

Article catalog Configuring NACOS Use mysql persistence Solve the problem that I don't support mysql8.x Login problem rely Profile Posted to get configuration release Obtain Start class Cluster constr...

SpringCloud NACOS, Configuration Center

Learning NaCOS as the use of registration, and NACOS can also serve as a configuration center in micro-service. This article teaches you how to build a configuration center. NACOS configuration manage...

SpringCloud Integrated NACOS Configuration Center Registration Center instance details

content First, SpringCloud Configuration NACOS Configuration Center 1, add configuration center dependence 2, bootstrap.yaml add configuration center configuration 3, NACOS client add configuration 4,...

SpringCloud Integrated Registration Center, Configuration Center Nacos (Nine)

Foreword In fact, EUREKA and CONFIG (or Apollo) are equivalent to previous use. This article is provided to beginners, the fastest and easiest to use NACOS. text 1. First run our NACOS service in the ...

More Recommendation

Nacos dynamic configuration center

What is nacos The full English name of Dynamic Naming and Configuration Service, NA is Naming/NameServer, as the registration center, CO is configuration, as the registration center. Service means tha...

SPINGBOOT2.X Integrated NACOS Configuration Center DEMO

SPINGBOOT2.X Integrated NACOS Configuration Center DEMO 1 Page configuration information add 1.1 New Naming Space 1.2 Add configuration information 2 dependencies 3 Configuration information settings ...

springcloud dynamic configuration center

Steps to use mars dynamic configuration center   1. Clone the github project to the local address:https://github.com/fashionbrot/mars-config.git   2. Find the init.sql wear library mars_test...

SpringCloud Series Configuration Center

concept Unified management of micro-service profiles   Architecture diagram of the micro service integration configuration center   Profile format   Name: Micro Service Name Profile: En...

Nacos SpringCloud configuration center use

Nacos Server installation Please refer to Nacos installationNacos source code entry running configuration Create project Use IntelliJ IDEA to create a Spring Boot project, the version is2.2.1.RELEASE ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top