查看网卡信息
ipconfig
#-dev -bind 设定绑定网卡,直接就启动服务了
#通过agent命令,来启动consul 服务
consul agent -dev -bind 192.168.43.208 -server -bootstrap -data-dir D:/tmp/consul
----这个命令才能所有机器访问
consul agent -dev -bind 172.23.3.197 -server -bootstrap -data-dir D:/tmp/consul -client 0.0.0.0 -ui
application.properties
spring.application.name=nannan
server.port=24543
spring.cloud.consul.host=127.0.0.1
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.health-check-url=http://10.20.12.24:8898/asset/registration/actuator/health
spring.cloud.consul.discovery.register=true
#\u6CE8\u518C\u5230consul\u7684\u670D\u52A1\u540D\u79F0
spring.cloud.consul.discovery.acl-token=123456
spring.cloud.consul.discovery.tags=dev
spring.cloud.consul.discovery.health-check-interval=15s
#\u6539\u7528ip\u4F5C\u4E3Adocker\u4E4B\u95F4\u7684\u901A\u4FE1\u65B9\u5F0F
spring.cloud.consul.discovery.prefer-ip-address=true
pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency><!--健康检查相关依赖,后面会用到-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>