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 

答えて

5

春ブーツです設定はOKです。

enter image description here

を下回るようなものですが、その後、再起動し8500とキー/値を選択して設定を作成it.then作成などの

enter image description here

下のキー値を追加します。その後、ローカルホストを使用して、領事のUIに行きますあなたのspringbootアプリケーション。 8084.

ノートにあなたのポート変更:あなたはより多くの設定のためにYMALまたはGIT2consulを使用することができます

関連する問題