当前位置: 首页 > news >正文

查询公司营业执照的网站男女在床上做羞羞的事的网站

查询公司营业执照的网站,男女在床上做羞羞的事的网站,新网站大量收录好不好,注册咨询公司经营范围一、使用openfeig调用远程另外一个服务接口 1、创建一个spring boot工程,并且创建2个模块来当微服务模块 2、分别配置2个模块的启动文件 3、分别两个模块下创建一个测试的控制器 4、在项目的根目录的pom.xml中添加spring-cloud配置 <properties><java.version>1…

一、使用openfeig调用远程另外一个服务接口

  • 1、创建一个spring boot工程,并且创建2个模块来当微服务模块

  • 2、分别配置2个模块的启动文件

  • 3、分别两个模块下创建一个测试的控制器

  • 4、在项目的根目录的pom.xml中添加spring-cloud配置

    <properties><java.version>1.8</java.version><spring-cloud.version>2021.0.8</spring-cloud.version>
    </properties>
    
    <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>
    
  • 5、在需要调用别的服务的项目中添加依赖

    <!--    远程调用的包    -->
    <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
    <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-loadbalancer</artifactId>
    </dependency>
    
  • 6、在需要调用别的 服务的项目中创建一个文件夹feign,里面创建一个文件SystemFeignHello.java的接口

    package com.example.feign;import org.springframework.cloud.openfeign.FeignClient;
    import org.springframework.web.bind.annotation.GetMapping;@FeignClient(name = "system", url = "http://localhost:9001/system")
    public interface SystemFeignHello {/*** 别的地方调用hell1方法的时候就会调用http://localhost:9001/system/hello路由* @return*/@GetMapping("hello")String hello1();
    }
    
  • 7、测试调用另外一个服务的接口

    package com.example.controller;import com.example.feign.SystemFeignHello;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RestController;import javax.annotation.Resource;@RestController
    public class HelloController {@ResourceSystemFeignHello systemFeignHello;@GetMapping("hello")public String hello() {return "File Hello";}@GetMapping("systemHello")public String getHello() {String helloResult = this.systemFeignHello.hello1();System.out.println(helloResult+"返回数据");return helloResult;}
    }
    
  • 8、在调用服务的启动类上加上扫描注解

    package com.example;import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.openfeign.EnableFeignClients;@SpringBootApplication
    @EnableFeignClients("com.example.feign")
    public class FileApplication {public static void main(String[] args) {SpringApplication.run(FileApplication.class, args);}}
    
  • 9、网页上测试调用接口

  • 10、system项目中接口如下,和普通接口没任何区别

    package com.example.controller;import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RestController;@RestController
    public class HelloController {@GetMapping("hello")public String hello() {return "System Hello11";}
    }
    

二、使用eureka来服务端配置

  • 1、eureka分为服务端和客户端,需要在项目中先创建一个eureka的服务段,在子项目中使用客户端的方式连接

  • 2、创建一个eureka模块来做服务端

  • 3、在eureka模块中添加依赖包

    <dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency>
    </dependencies>
    
  • 4、配置文件中基本配置

    spring.application.name=eureka
    server.port=8761
    eureka.client.fetch-registry=false
    eureka.client.register-with-eureka=false
    
  • 5、在启动类上添加注解

    package com.example;import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication
    @EnableEurekaServer
    public class EurekaApplication {public static void main(String[] args) {SpringApplication.run(EurekaApplication.class, args);}}
    
  • 6、直接在浏览器上输入http://localhost:8761/如下就表示配置成功

    在这里插入图片描述

三、客户端配置

  • 1、引入依赖包

    <!--    客户端端    -->
    <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    
  • 2、在配置文件中添加

    eurec.client.server-url.defaultZone=http://localhost:8761/eureka/
    
  • 3、在启动文件中添加

    @SpringBootApplication
    @EnableEurekaClient
    public class SystemApplication {public static void main(String[] args) {SpringApplication.run(SystemApplication.class, args);}}
    
  • 4、刷新浏览器查看服务是否已经注册成功

    在这里插入图片描述

四、网关的配置

  • 1、创建一个网关模块

  • 2、在网关中引入依赖包

    <dependencies><!-- 网关依赖 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--    客户端端    --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency>
    </dependencies>
    
  • 3、修改配置文件

    server.port=8000
    spring.application.name=gateway
    server.servlet.context-path=/gateway
    spring.main.web-application-type=reactive 
    eurec.client.server-url.defaultZone=http://localhost:8761/eureka/# 注册一个服务
    spring.cloud.gateway.routes[0].id=system
    spring.cloud.gateway.routes[0].uri.=http://localhost:9001
    spring.cloud.gateway.routes[0].predicates[0].name=Path
    spring.cloud.gateway.routes[0].predicates[0].args[0]=/system/**
    # 注册一个服务
    spring.cloud.gateway.routes[1].id=file
    spring.cloud.gateway.routes[1].uri.=http://localhost:9000
    spring.cloud.gateway.routes[1].predicates[0].name=Path
    spring.cloud.gateway.routes[1].predicates[0].args[0]=/file/**
    
  • 4、启动文件

    package com.example;import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;@SpringBootApplication
    @EnableEurekaClient
    public class GatewayApplication {public static void main(String[] args) {SpringApplication.run(GatewayApplication.class, args);}}
    
  • 5、使用网关的地址直接访问别的路由http://localhost:8000/system/hello

http://www.yayakq.cn/news/647228/

相关文章:

  • 小型营销企业网站建设策划一个网站要多少钱
  • 鹤峰网站建设制作一个门户网站需要多少钱
  • 酒店手机网站首页设计太原顶呱呱做网站地址电话
  • 容易被百度收录的网站金华网站建设公司哪家好
  • 常德网站优化公司做游戏网站的目地
  • 惠州市+网站开发公司江浦企业管理咨询服务有限公司
  • 怎么建个废品网站西安免费网站建站模板
  • 莱州网站建设价格百度站内搜索
  • 昌吉北京网站建设爱站网怎么打不开
  • 怎么做可以看外国视频网站杭州网站建设哪个好
  • 南昌旅游集团网站建设品牌建设规划方案
  • 那个网站可以做考卷那个网站的域名便宜
  • 网站备案时间wordpress表格边框
  • 中小企业网站建设价格如何用手机建网站
  • 怎样建设一个韩国网站wordpress外贸数码
  • 台山网站设计群晖 nas wordpress
  • 青海网站开发 建设小程序推广是干什么的
  • 广东网站建设报价官网dedecms 网站根目录
  • 安徽网站建设网站运营怎样做网络推广优选豪升网络好
  • 网站模板演示怎么做wordpress提交友情链接
  • 最新的网站开发技术网站建设的功能描述
  • 龙口网站建设联系电话WordPress添加ftp
  • 高端大气的网站首页深圳市城市建设管理局
  • 网站分辨率做96是否会更好怎么给一个花店做网站建设
  • 做商城网站需要什么条件营销计划的主要内容
  • 开发者门户网站是什么意思宁波网络推广咨询
  • 承接网站开发律师微网站建设
  • 自适应营销网站淘宝做个网站多少钱
  • 南昌网站开发培训学校wordpress 店铺插件
  • 做农产品的网站教育品牌加盟网站建设