Config Server can also add a user name and password. the Config client is accessed through a user name and password.
Config Server can also be made into a highly available cluster.
Config is used with the Eureka configuration. Register Config server to Eureka. Config Client is also registered to Eureka.
PackageCom.itmuch.cloud;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;Importorg.springframework.cloud.client.discovery.EnableDiscoveryClient;Importorg.springframework.cloud.config.server.enableconfigserver;@ Springbootapplication@enableconfigserver@enablediscoveryclient Public classserverapplication { Public Static voidMain (string[] args) {Springapplication.run (serverapplication.class, args); }}
Server: 8080Spring: Cloud: config: server: git: uri:https:// Git.oschina.net/it-much/config-repo-51cto-video username: Password: application: name:microservice-config-server-eurekaeureka: #config-server registered to Eureka Client: serviceurl: defaultzone:http://user:[email Protected]:8761/eureka instance: prefertrue
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelversion>4.0.0 </modelVersion> <parent> <groupId>com.itmuch.cloud</groupId> <artifactid>mi Croservice-spring-cloud</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> < Artifactid>microservice-config-server-eureka</artifactid> <packaging>jar</packaging> < Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> ; <dependencies> <!--config-server Dependency, Config-server registered to Rureka---<dependency> &L T;groupid>org.springframework.cloud</groupid> <ARTIFACTID>SPRING-CLOUD-CONFIG-SERVER</ARTIFAC Tid> </dependency> <!--eureka-client Dependencies--<dependency> <groupid >org.springframework.cloud≪/groupid> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> </dependencies> <build> <defaultGoal>compile</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifact Id>maven-surefire-plugin</artifactid> <version>2.12.3</version> <con figuration> <groups>unit</groups> </configuration> </ Plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <verbose>true</verbose> <fork>true</fork> <compilerVersion>1.5</compilerVersion> </configuration> </plugin> </plugins> </build></project>
PackageCom.itmuch.cloud;ImportOrg.springframework.beans.factory.annotation.Value;Importorg.springframework.web.bind.annotation.GetMapping;ImportOrg.springframework.web.bind.annotation.RestController; @RestController Public classConfigclientcontroller {@Value ("${profile}") PrivateString profile; @GetMapping ("/profile") PublicString GetProfile () {return This. Profile; }}
PackageCom.itmuch.cloud;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;Importorg.springframework.cloud.client.discovery.enablediscoveryclient;@ Springbootapplication@enablediscoveryclient Public classconfigserverapplication { Public Static voidMain (string[] args) {Springapplication.run (configserverapplication.class, args); }}
Application.yml
Server: 8081
Bootstrap.yml
Spring: Cloud: config: discovery: true service-id: microservice-config-server-Eureka #config server in Eureka's name application: name:foobar Eureka: #把config client registered to Eureka client: serviceurl: defaultzone:http:// User:[email Protected]:8761/eureka instance: prefertrue
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelversion>4.0.0 </modelVersion> <parent> <groupId>com.itmuch.cloud</groupId> <artifactid>mi Croservice-spring-cloud</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> < Artifactid>microservice-config-client-eureka</artifactid> <packaging>jar</packaging> < Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> ; <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-web< ;/artifactid> </depenDency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency > <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-a Ctuator</artifactid> </dependency> </dependencies></project>
Configuration attribute plus decryption:
configured in the git repository is clear text,
Download Jce8:
Http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
Unzip after download:
inside is a 2 -plus decryption strategy file. Use these 2 policy files to replace the JDK 's policy files.
SPRINGCLOUD20---config join Eureka