SpringCloud:Eureka Config項目搭建(Gradle項目)


Eureka Config分為Config Server 和Config Client兩部分。

Config Server部分:

gradle配置:

 

// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-config-server
    compile group: 'org.springframework.cloud', name: 'spring-cloud-config-server', version: '2.0.2.RELEASE'

    // https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka-server', version: '1.4.6.RELEASE'

 

 

 

application.yml:

eureka:
    client:
        serviceUrl:
            defaultZone: http://localhost:8761/eureka/
server:
  port: 8888

spring:
  cloud:
    config:
      server:
        git:
          uri: https://gitee.com/bensonlim/springcloud/
          searchPaths: helloworldConfig
  application:
    name: config-server

 

EurekaconfigApplication.java
@EnableEurekaServer
@EnableConfigServer
@SpringBootApplication
public class EurekaconfigApplication {

	public static void main(String[] args) {
		SpringApplication.run(EurekaconfigApplication.class, args);
	}

}

  

 

Config Client部分:

 

application.yml:

spring:
  application:
    name: config-client
  cloud:
    config:
      label: master
      profile: dev
      uri: http://localhost:8888/
server:
  port: 8881
ConfigclientApplication.java
@SpringBootApplication
@RestController
public class ConfigclientApplication {

	public static void main(String[] args) {
		SpringApplication.run(ConfigclientApplication.class, args);
	}

	@Value("${hello}")
	String hello;
	@RequestMapping(value = "/hello")
	public String hello(){
		return hello;
	}

}

  

 

https://gitee.com/bensonlim/springcloud/tree/master/helloworldConfig

 

配置自動刷新:

引入acurator

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM