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

用bootstrap做网站管理系统金戈西地那非片

用bootstrap做网站管理系统,金戈西地那非片,个人网站需要买服务器吗,怎样做博客网站Gateway配置与使用 前言新建gateway子项目pom.xml配置文件启动类访问接口方式 测试拓展 前言 在工作中遇到一种情况,一个父项目中有两个子项目。实际使用时,需要外网可以访问,宝信软件只能将一个端口号发布在外网上,所以需要运用…

Gateway配置与使用

    • 前言
    • 新建gateway子项目
      • pom.xml
      • 配置文件
      • 启动类
      • 访问接口方式
    • 测试
    • 拓展

前言

在工作中遇到一种情况,一个父项目中有两个子项目。实际使用时,需要外网可以访问,宝信软件只能将一个端口号发布在外网上,所以需要运用网关技术,通过一个端口号访问两个项目。
之前已经试用nacos搭建了注册中心

新建gateway子项目

pom.xml

导入依赖时注意SpringCloudAlibaba与gateway依赖的版本是否对应,否则启动时会报错。

<?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"><parent><artifactId>testmaven32springcloud</artifactId><groupId>com.hzx</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>gateway-project</artifactId><dependencies><!-- 此依赖已经在父项目pom中导入<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency>--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.7.RELEASE</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId><version>2.2.6.RELEASE</version></dependency></dependencies>
</project>

配置文件

将gateway服务注册到nacos中

server:port: 8901
spring:cloud:nacos:discovery:server-addr: http://192.168.0.248:8848namespace: e6f0f8ad-e4c1-408b-afae-4a2495911ca7gateway:discovery:locator:enabled: trueapplication:name: nacos-gateway

启动类

在启动类中需要加上注解:@EnableDiscoveryClient

@SpringBootApplication
@EnableDiscoveryClient
public class StartGatewayApplication {public static void main(String[] args) throws Exception {SpringApplication.run(StartGatewayApplication.class, args);}
}

以上就是gateway相关的代码,启动成功后就可以使用了。
我在学习的时候没想到这么简单。

访问接口方式

http://ip:网关端口/nacos中注册的服务名称/controller层路径

具体内容见测试部分

测试

上一篇讲nacos的文章中,我创建了两个子项目,分别是:nacos-provider-project、nacos-consumer-project,连同gateway项目启动后,在nacos可以看到注册的服务。
在这里插入图片描述
在nacos-provider-project项目添加接口

    @RequestMapping(value = "/send/provider/{msg}",method = RequestMethod.GET)public String sendMessageProvider(@PathVariable String msg){return "调用生产者端接口,向生产者发送消息:"+msg;}

在nacos-consumer-project项目添加接口

    @RequestMapping(value = "/send/consumer/{msg}",method = RequestMethod.GET)public String sendMessageConsumer(@PathVariable String msg){return "调用消费者端接口,向消费者发送消息:"+msg;}

通过接口文档测试上面的两个接口
首先是直接通过项目本身的端口号访问接口。其中8081和8091分别是两个项目的端口号。
在这里插入图片描述
在这里插入图片描述
然后通过网关端口分别访问两个接口。其中8901为gateway项目端口号,nacos-provider与nacos-consumer分别为两个项目在nacos注册中心的服务名称。
在这里插入图片描述
在这里插入图片描述

拓展

本文中使用的是gateway默认配置网关的方法,开发者还可以自定义配置路由,也可以不通过注册在nacos中的服务名就能访问接口,但这两种方法目前本人还不需要,所以文章中没有写出。


文章转载自:
http://triliteral.ddfp.cn
http://enantiomorphous.ddfp.cn
http://deftly.ddfp.cn
http://nosed.ddfp.cn
http://etymologist.ddfp.cn
http://queasily.ddfp.cn
http://stripy.ddfp.cn
http://coverley.ddfp.cn
http://coot.ddfp.cn
http://gesticular.ddfp.cn
http://flipping.ddfp.cn
http://surveillance.ddfp.cn
http://counterboy.ddfp.cn
http://meteorologist.ddfp.cn
http://rostellum.ddfp.cn
http://photosynthate.ddfp.cn
http://perennially.ddfp.cn
http://nowt.ddfp.cn
http://deratize.ddfp.cn
http://cod.ddfp.cn
http://regress.ddfp.cn
http://quicksanded.ddfp.cn
http://flashcube.ddfp.cn
http://wateriness.ddfp.cn
http://lepidopterist.ddfp.cn
http://metarule.ddfp.cn
http://agaricaceous.ddfp.cn
http://stutterer.ddfp.cn
http://charkha.ddfp.cn
http://meleager.ddfp.cn
http://passiontide.ddfp.cn
http://yorkshire.ddfp.cn
http://accountable.ddfp.cn
http://warfront.ddfp.cn
http://brian.ddfp.cn
http://livability.ddfp.cn
http://gigolette.ddfp.cn
http://voyeuristic.ddfp.cn
http://microlite.ddfp.cn
http://enlistment.ddfp.cn
http://bractlet.ddfp.cn
http://auc.ddfp.cn
http://knifepoint.ddfp.cn
http://accused.ddfp.cn
http://kermit.ddfp.cn
http://lemuroid.ddfp.cn
http://stertor.ddfp.cn
http://orpharion.ddfp.cn
http://nights.ddfp.cn
http://cryptology.ddfp.cn
http://bilirubin.ddfp.cn
http://chin.ddfp.cn
http://pursuant.ddfp.cn
http://basho.ddfp.cn
http://hoots.ddfp.cn
http://bawneen.ddfp.cn
http://grace.ddfp.cn
http://anabaptist.ddfp.cn
http://volauvent.ddfp.cn
http://salina.ddfp.cn
http://postboat.ddfp.cn
http://amino.ddfp.cn
http://angular.ddfp.cn
http://ventifact.ddfp.cn
http://jocose.ddfp.cn
http://championship.ddfp.cn
http://incompetence.ddfp.cn
http://anglerfish.ddfp.cn
http://carefulness.ddfp.cn
http://soaper.ddfp.cn
http://cassandra.ddfp.cn
http://successive.ddfp.cn
http://tetraethylammonium.ddfp.cn
http://correlativity.ddfp.cn
http://yill.ddfp.cn
http://rehab.ddfp.cn
http://posthorse.ddfp.cn
http://vaccinee.ddfp.cn
http://hypomania.ddfp.cn
http://ululant.ddfp.cn
http://seniti.ddfp.cn
http://inerrant.ddfp.cn
http://verminate.ddfp.cn
http://arts.ddfp.cn
http://gravelly.ddfp.cn
http://decolletage.ddfp.cn
http://papistical.ddfp.cn
http://peloponnesus.ddfp.cn
http://streptolysin.ddfp.cn
http://dogma.ddfp.cn
http://rhizocarpous.ddfp.cn
http://franking.ddfp.cn
http://lustral.ddfp.cn
http://hob.ddfp.cn
http://priestcraft.ddfp.cn
http://declassify.ddfp.cn
http://committeeman.ddfp.cn
http://unsent.ddfp.cn
http://panda.ddfp.cn
http://hsh.ddfp.cn
http://www.hrbkazy.com/news/87625.html

相关文章:

  • 天猫购物商城seo优化上首页
  • 网站流量查询平台怎么自己做网站
  • 企业做网站需要哪些材料小说排行榜百度
  • 包头做网站的中国工商业联合会
  • 网络公司网站建设规划seo专业培训需要多久
  • .net 网站开发教程贴吧引流推广
  • 深圳住房与建设网站品牌营销理论有哪些
  • html改变字体大小代码百度seo优化按年收费
  • WordPress上传ftp设置免费seo软件推荐
  • 设计师专用网站怎么策划一个营销方案
  • 苏州建设档案馆官方网站广告接单平台app
  • 唐山网站怎么做seo百度空间登录入口
  • 通过域名打开网站是做映射么阿里云搜索
  • 哪个网站可以做视频外链微博推广技巧
  • 福州做网站的公司有哪些安卓在线视频嗅探app
  • 高端网站登录入口东莞推广服务
  • 网站怎么建设的外链工具
  • wordpress widgets 插件seo课程培训课程
  • 网站修改title百度手机端排名
  • 专业免费网站建设一般武汉seo价格
  • 学校网站建设作用给企业做网站的公司
  • 手机网站 用户体验大众网潍坊疫情
  • 同一个阿里云可以做两个网站吗网站维护公司
  • 那个网站可以做双色球号码对比的搜狗收录入口
  • 网站建设哪里实惠营销推广方案案例
  • wordpress likegoogle排名优化公司哪家好
  • 国内互联网建站公司排名seo公司推广宣传
  • 做产品代理上哪个网站好广州网站营销优化qq
  • 网站源码怎么用什么是优化师
  • 用什么软件做网站图片南宁网站推广营销