其他分享
首页 > 其他分享> > 服务提供者

服务提供者

作者:互联网

新建项目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";
    }
}

 

标签:spring,服务提供者,boot,eureka,provider,microservice,cloud
来源: https://blog.csdn.net/qq_34625785/article/details/95213391