Spring Cloud 入门 Consul-Client服务提供
程序员文章站
2022-04-24 16:38:02
前面介绍了 Rureka Client服务提供, 只需要改pom.xml部分内容 1、pom.xml 2、application配置 主要改动就这2块,其他如参照上一篇Eureka-Client ......
前面介绍了 Rureka Client服务提供, 只需要改pom.xml部分内容
1、pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>consulClient</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>consulClient</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </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> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-consul-dependencies</artifactId> <version>1.0.1.RELEASE</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>
2、application配置
spring.application.name=consulClient server.port=1001 spring.cloud.consul.host=127.0.0.1 spring.cloud.consul.port=8500
主要改动就这2块,其他如参照上一篇Eureka-Client
推荐阅读
-
Spring Cloud开发人员如何解决服务冲突和实例乱窜?(IP实现方案)
-
Spring Cloud入门程序
-
详解Spring Cloud Gateway基于服务发现的默认路由规则
-
SpringCloud之服务注册与发现Spring Cloud Eureka实例代码
-
Spring Cloud Alibaba | Sentinel: 服务限流高级篇
-
Spring Cloud第七篇 | 声明式服务调用Feign
-
[Spring cloud 一步步实现广告系统] 11. 使用Feign实现微服务调用
-
微服务架构下使用Spring Cloud Zuul作为网关将多个微服务整合到一个Swagger服务上
-
Spring Cloud Alibaba | Nacos服务中心初探
-
spring cloud 入门系列八:使用spring cloud sleuth整合zipkin进行服务链路追踪