新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Idea下SpringCloud2实验(二、Eureka-服务提供者)-创新互联

一、创建SpringBoot项目springcloud-eureka-client-order,过程如上一篇,有一点需要注意,选择Eureka客户端依赖
Idea下SpringCloud2实验(二、Eureka-服务提供者)

10年积累的成都做网站、网站建设、外贸营销网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有莲池免费网站建设让你可以放心的选择与我们合作。

二、配置文件
1、pom.xml



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.4.RELEASE
         
    
    com.jane
    springcloud-eureka-client-order
    0.0.1-SNAPSHOT
    springcloud-eureka-client-order
    Demo project for Spring Boot

    
        1.8
        Greenwich.SR1
    

    
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
        
            org.springframework.cloud
            spring-cloud-starter-openfeign
            2.0.2.RELEASE
        
        
            org.springframework.cloud
            spring-cloud-openfeign-core
            2.0.2.RELEASE
        
        
            io.github.openfeign.form
            feign-form-spring
            3.2.2
        
        
    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

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-服务提供者)

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


本文题目:Idea下SpringCloud2实验(二、Eureka-服务提供者)-创新互联
文章源于:http://www.wjwzjz.com/article/dgscsj.html
在线咨询
服务热线
服务热线:028-86922220
TOP