24 Ekim 2022 Pazartesi

SpringCloud Consule

Giriş
Şeklen şöyle

Maven
Şöyle yaparız
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>${spring-cloud.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
    
...
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
...
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
application.yaml şöyledir
# enable all the actuator endpoints
management:
  endpoints:
    web:
      exposure:
        include: "*"
        
# spring cloud configuration, exposes 
# the micrometer metrics and registers to consul
spring:
  application:
    name: my-service
  cloud:
    consul:
      host: localhost
      port: 8500
      discovery:
        # instance-id must not be empty, must start with letter, 
        # end with a letter or digit, and have as interior characters 
        # only letter, digits, and hyphen
        instance-id: ${spring.application.name}-${node.name}-micrometer-instance
        serviceName: ${spring.application.name}
        register: true
      retry: 
        initial-interval: 2000
        max-attempts: 10000
        max-interval: 4000
        multiplier: 1.1




Hiç yorum yok:

Yorum Gönder