服务提供者

新建项目microservice-provider-user

 

<?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">
    <parent>
        <artifactId>spring-cloud-microservice-study</artifactId>
        <groupId>com.itmuch.cloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>microservice-provider-user</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <!-- 添加Eureka的依赖 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>
</project>

application.yml

server:
  port: 8000
spring:
  application:
    name: icroservice-provider
eureka:
  client:
    service-url:
       defaultZone: http://127.0.0.1:8761/eureka/


  instance:
    prefer-ip-address: true

提供者接口

@RestController
public class Controller {


    @GetMapping("/{id}")
    public String findById(@PathVariable Long id) {

        return "Hello";
    }
}

服务提供者

服务提供者

 

上一篇:Feign使用Hystrix(断路器的使用)


下一篇:Ribbon负载均衡及Feign消费者调用服务