Create a Git repository for your configuration files

  1. Create a new module: config

    Use as an empty folder

  2. Copy the application.yml of project 2,3,4,11 into the config directory and rename it

    • item-service-dev.yml
    • user-service-dev.yml
    • order-service-dev.yml
    • zuul-service-dev.yml
Spring is added in the dev. Yml. Cloud. Config. Override - none: true
  1. The submission is pushed to the remote repository
  2. Finally, clear out the four itemsapplication.ymlfile

“Dev” is the name of the profile. It can be written dev /test /prod.

Build the config server of the configuration center

The config config center downloads all configuration files from the Git repository, while other microservices are obtained from the config config center

  1. Create the config configuration center project
  2. Add config server/eureka client dependency
  3. Configuration application. Yml: application name/git. Uri: configuration warehouse path/git. SearchPaths: config/server port/eureka defaultZone
  4. Startup class adds annotations:@EnableConfigServer

Configure the client of the center

Modify items 2,3,4,11

  1. Add a Config Client dependency
  2. New configuration filebootstrap.yml

    Yml Bootstrap. yml performs a boot (initialization) operation when the SpringBoot project starts before loading Application.yml

  3. configuration

    • eureka
    • Configure the service ID of the center
    • Which configuration file to download