A Preliminary Study of Spring (3) config

Server:
1. To create a project, please refer to the demo project
2. Add pom.xml in the project, note that if you do not add spring-boot-starter-actuator, the client will report an error
<dependency>
    <groupId>org.springframework.boot</ groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
    < version>1.3.3.RELEASE</version>
</dependency>
3. Add the @EnableConfigServer annotation to the startup type to start the configServer function
4. Configure the application.porperties property.
  server.port=8888 #Property
  file address
  spring.cloud.config.server.git.uri=https://github.

  #spring.cloud.config.server.git.searchPaths=
  #Branch
  spring.cloud.config.label=master
5. Start, the program is successful.
git address: https://github.com/leaf-it/demo-config-server
Client:
1. To create a project, please refer to the demo project 2. Add <dependency>      <groupId>org.springframework
to pom.xml in the project . cloud</groupId>      <artifactId>spring-cloud-starter-config</artifactId>      <version>1.3.3.RELEASE</version> </dependency> 3. When using the syntax ${property name}, the property file can Do not write its properties, but specify the configuration server.    @Value("${hello:defaultValue}")       String hello;    configure server:    spring.cloud.config.label=master    spring.cloud.config.profile=dev











   spring.cloud.config.uri= http://localhost:8888/
4. Start, the program is successful, http://localhost:5555/con/hello can be tested. In the example, the addition of eureka and swagger is for debugging. If it is not registered, it can be omitted and the simplest version.
5. Remaining problems: Adding @@RefreshScope to the controller should be its own initiative to refresh the data, but the experimental results cannot.
  And when I checked it in swagger, I didn't see its interface exposed. I made a mark here, and I will check it when I have time.
git address: https://github.com/leaf-it/demo-config-client







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326214352&siteId=291194637