2
登録サーバを "Eureka"から "Consul"に変更し、Consulも自分の設定サーバとして変更しようとしました。領事とのサービスディスカバリーは成功です。しかし、アプリケーションをブートストラップするためにキー/バリューペアオプションを取得する方法を理解できません。私はそれを行うことができる方法はありますか?以下スプリングブート時のコンサル鍵値ペアの使用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
を依存関係で
私は春のブートを使用し、これはConsuleDemoApplication.class
@EnableDiscoveryClient
@SpringBootApplication
@RestController
public class ConsuleDemoApplication {
@RequestMapping("/")
public String home() {
return "Hello world";
}
public static void main(String[] args) {
SpringApplication.run(ConsuleDemoApplication.class, args);
}
}
私の春ブーツアプリで、私のbootstrap.ymlは
spring:
cloud:
consul:
discovery:
healthCheckInterval: 15s
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
application:
name: consul_demo