SpringBoot integrated NACOS for dynamic configuration

tags: springboot  java  spring boot  nacos

Table of contents

What is NACOS?

Windows installation NACOS?

nacos configuration database

SpringBoot integrated NACOS


  1. What is NACOS?

    1. What is nacos? I will not introduce it in detail, you can read it directlyOfficial document https://nacos.io/zh-cn/docs/quick-start.htmlicon-default.png?t=L892https://nacos.io/zh-cn/docs/quick-start.html
  2. Windows installation NACOS?

    1. download link https://github.com/alibaba/nacos/releases
    2. Press the downloaded zip package
    3. Enter the bin directory to execute Startup.cmd -m Standalone

    4. Default access address

    5. The default account/password is nacos/nacos

  3. nacos configuration database

    1. Enter the Conf folder and find the Nacos-Mysql SQL file to create a database NACOS and import the script
    2. Find Application.properties file to modify the following configuration

       
    3. Just restart the service
  4. SpringBoot integrated NACOS

    1. First build a new SpringBoot project
    2. Import nacos dependencies
    3. Set the configuration source note to the start class 
    4. Configure Application.yaml in Nacos

         

    5. Start service
    6. Write test interface
      @Controller
      @RequestMapping("config")
      public class ConfigController {
      
          @NacosValue(value = "${useLocalCache:true}", autoRefreshed = true)
          private boolean useLocalCache;
      
          @GetMapping(value = "/get")
          @ResponseBody
          public boolean get() {
              return useLocalCache;
          }
      }
    7. Test interface

                   

Intelligent Recommendation

SpringBoot integrates NacOS, YAML configuration, integrated version

Write a directory title here 1. Introduction to NACOS 2. NACOS integrated SpringBoot dependencies 3. YAML configuration 4. Verify Refresh refresh 1. Introduction to NACOS NACOS Ali's open source confi...

SpringBoot 06 Integrated NACOS Implementation Configuration Center

1. Why use nacos NACOS has been applied to configuration management by many companies because of its excellent reading and writing performance and simple and flexible configuration. NACOS is developed...

springboot integrated Appollo dynamic configuration

  New pom-dependent:    <!-- https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client --> <dependency>     <groupId>com.ctrip.fr...

Springboot + Nacos Dynamic Configuration - Personal Notes

Packet Version you choose NACOS configuration file bootstrap.yml Bootstrap.yml is preferred than Application.yml Springboot configuration file...

Springboot uses NACOS dynamic configuration data sources

After the SpringBoot / SpringCloud project is deployed, if you use a hard-coded method to define the data source, then if you need to replace the database, you can only reach your source by changing t...

More Recommendation

SpringBoot project integrates NACOS with dynamic configuration files

Add configuration in the configuration file Directly injected Then add annotations to the startup class Then inject the parameters directly in the place where the parameters need to be injected; Add t...

springboot integrated nacos

nacos mainly configuration management and service discovery, if you do not understand these two concepts recommended in the case of you can go to find out the basic principles of configuration managem...

Java Springboot integrated NACOS

NACOS Register 1) Project Add Dependency Pack 2) NACOS-web engineering add configuration file bootstrap.yml 3) NACOS-web project Add startup class 4) NACOS-web project New InfoController 5) Start the ...

Springboot integrated Dubbo + Nacos

Springboot server configuration provider 1.pom introduced JAR package 2. Startup class Add Application.yml configuration 4.Service implementation class configuration Springboot consumer side configura...

Spring Cloud Gateway integrated NACOS to implement dynamic configuration loading

I. Introduction As the entrance of the entire microservices cluster, the gateway assumes the certification and authorization of external requests. At the same time as the gateway, frequent changes in ...

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

Top