成都创新互联网站制作重庆分公司

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

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

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及水电改造等,在网站建设公司全网营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

二、配置文件
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-服务提供者)


当前名称:Idea下SpringCloud2实验(二、Eureka-服务提供者)
标题网址:http://cxhlcq.com/article/gicgjd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部