SPRINGCLOUD20---config join Eureka

Source: Internet
Author: User

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&gt        ; <dependencies> <!--config-server Dependency, Config-server registered to Rureka---<dependency> &L T;groupid>org.springframework.cloud</groupid> &LT;ARTIFACTID&GT;SPRING-CLOUD-CONFIG-SERVER&LT;/ARTIFAC Tid> </dependency> <!--eureka-client Dependencies--<dependency> <groupid >org.springframework.cloud&Lt;/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&gt    ;            <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&lt ;/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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.