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