When we build a project using a distributed architecture, for example, we changed the database password.
So if there are more than 10 microservices configured on different servers we're going to have to change one server
That's a lot of trouble, not just trouble, it's easy to be wrong, so it's impossible.
Here is a workaround to put the project configuration on the Gitlab from Gitlab to read so that we can easily configure
Then we're going to log on to Gitlab, create an account, publish the project, and so on.
79099772 This tutorial take a look here not much to say
Then create a configuration center module in the project
// Https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-config-server Compile group: ' Org.springframework.cloud ', Name: ' Spring-cloud-config-server '
Add Config-server dependencies because it is the configuration hub server that needs to be added on the client side
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-config Compile group: ' Org.springframework.cloud ', Name: ' Spring-cloud-starter-config '
Then look down to the configuration file for configuration center
Spring: application: name:config-Center//Project name Cloud: config: server: git: Uri:https: // gitlab.com/wangkeee/poppy-mall.git Search-paths:local//Read that folder in the Project Server :8887//Port number
Note that the configuration file here needs to use BOOTSTRAP.YML instead of the previously used APPLICATION.YML
They're basically the same, but Bootstrap.yml's execution is preferable to application.yml.
Think of the configuration file when reading the project of course it needs to be read first in the Local. It's okay to put the config file on git and read slowly so you need to read it first.
And look at the GIT project building.
Create a configuration file for the microservices in the folder and copy the contents of the MicroServices configuration file
The name of the file is in the configuration file
Spring: Application: Name:
The value of the. yml
Then you can delete the corresponding micro-service configuration file and add a bootstrap.yml
Look at the configuration inside.
Spring: application: name:project-poppy-Mall//project name Cloud: config: uri:http: //localhost:8887//Configuration Center address
On the startup class in Configuration center, add
// Start Project // On behalf of it is a configuration center
Then you can run the configuration center and it will run successfully.
Then you can run the micro-service that deleted the configuration file as usual if you want to change the configuration file of the microservices only need to make a change on the login Gitlab is very convenient
Spring Cloud Distributed configuration (remote configuration using GIT)