Spring Boot版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

spring cloud依赖版本

版本号选择:(点进去往下翻翻!!!Spring CloudLevel up your Java code and explore what Spring can do for you.https://spring.io/projects/spring-cloud

 打不开的直接百度搜Spring Cloud进去;

 

需要spring cloud的什么jar,点进去找

   <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>2021.0.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

spring cloud依赖

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-kubernetes-fabric8-all</artifactId>
        </dependency>

Java

注解FeignClient中无需制定URL,录入服务名即可调用对应的服务!!!

@FeignClient(name = "serviceName", configuration = {FeignExceptionDecoder.class})
public interface FeignService {
    @PostMapping("/test")
    public BaseResult<List<Pod>> test(@PathVariable("clusterId") String clusterId);

    @GetMapping("/test2")
    BaseResult<List<Pod>> test2(@PathVariable String clusterId, @RequestParam String nodeName);
}

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐