中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Idea下SpringCloud2實驗(二、Eureka-服務提供者)

發布時間:2020-06-19 09:16:44 來源:網絡 閱讀:792 作者:shayang88 欄目:編程語言

一、創建SpringBoot項目springcloud-eureka-client-order,過程如上一篇,有一點需要注意,選擇Eureka客戶端依賴
Idea下SpringCloud2實驗(二、Eureka-服務提供者)

二、配置文件
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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jane</groupId>
    <artifactId>springcloud-eureka-client-order</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springcloud-eureka-client-order</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--open feign-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>2.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-core</artifactId>
            <version>2.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign.form</groupId>
            <artifactId>feign-form-spring</artifactId>
            <version>3.2.2</version>
        </dependency>
        <!--feign-->
    </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>

2、啟動文件

package com.jane.springcloudeurekaclientorder;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.ComponentScan;

@EnableDiscoveryClient
@SpringBootApplication
@ComponentScan("com.jane")
@EnableFeignClients
public class SpringcloudEurekaClientOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringcloudEurekaClientOrderApplication.class, args);
    }

}

3、application.properties

server.port=6010
spring.application.name=springcloud-eureka-client-order
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:6001/eureka/

4、服務提供API,TestController

package com.jane.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Value("${server.port}")
    String port;

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public String test(){
        return "hello,this is client-order:" + port;
    }

}

三、啟動服務
1、服務正常
Idea下SpringCloud2實驗(二、Eureka-服務提供者)
2、查看注冊中心
Idea下SpringCloud2實驗(二、Eureka-服務提供者)

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

德保县| 宁远县| 镇沅| 固阳县| 汕头市| 开封市| 登封市| 古浪县| 昌邑市| 封丘县| 陵川县| 社旗县| 阿图什市| 萍乡市| 满城县| 富平县| 大石桥市| 汉中市| 广西| 金乡县| 大厂| 黔西| 阿拉尔市| 英山县| 宜章县| 夏河县| 正宁县| 弥勒县| 原平市| 宜兰市| 临海市| 蒙阴县| 民丰县| 修文县| 吉安市| 西青区| 丰台区| 绥阳县| 芜湖市| 江山市| 资中县|