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

建设网站推广贷款业务泉州关键词搜索排名

建设网站推广贷款业务,泉州关键词搜索排名,电子商务网站的建设及规划,网页设计与网页制作课程总结实现以nacos为注册中心,网关路由转发调用 项目版本汇总项目初始化新建仓库拉取仓库项目父工程pom初始化依赖版本选择pom文件如下 网关服务构建pom文件启动类配置文件YMLnacos启动新建命名空间配置网关yml(nacos)网关服务启动 用户服务构建pom文件启动类配置文件YML新增url接口配…

实现以nacos为注册中心,网关路由转发调用

    • 项目版本汇总
    • 项目初始化
      • 新建仓库
      • 拉取仓库项目
      • 父工程pom初始化
      • 依赖版本选择
      • pom文件如下
    • 网关服务构建
      • pom文件
      • 启动类
      • 配置文件YML
      • nacos启动
      • 新建命名空间
      • 配置网关yml(nacos)
      • 网关服务启动
    • 用户服务构建
      • pom文件
      • 启动类
      • 配置文件YML
      • 新增url接口
      • 配置用户服务yml(nacos)
      • 用户服务启动
    • 测试路由转发
    • 源码地址

项目版本汇总

nacos2.1.1
springCloud2021.0.7
springboot2.6.14
spring-cloud-starter-alibaba-nacos-discovery2021.1
spring-cloud-starter-alibaba-nacos-config2021.1

项目初始化

新建仓库

可使用github/gitlab/码云等其它代码库,建立自己的项目仓库
我这里使用的是码云

码云地址

拉取仓库项目

git clone 你新建的仓库地址
下载后,用idea打开(这里默认你能配置maven,jdk以及java环境变量的操作)

父工程pom初始化

用途:该pom用于管理整个微服务项目的依赖框架和版本以及所属子模块等
如图所示:该pom.xml在工程的根目录下创建
在这里插入图片描述

依赖版本选择

  • 进入Spring官网Spring官网选择Project下的Springcloud栏进去
    在这里插入图片描述
  • 版本号对应关系一目了然
    在这里插入图片描述
  • 选择2021.0.x版本的cloud,那么对应的boot版本就是2.6-2.7之间

pom文件如下

spring-cloud-dependenciescloud依赖
spring-boot-dependenciesboot依赖
nacos-clientnacos版本
spring-boot-starter-test单测依赖
spring-cloud-starter-alibaba-nacos-discovery注册中心客户端依赖
spring-cloud-starter-alibaba-nacos-config配置中心客户端
<dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2021.0.7</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.6.14</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>2.1.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>${boot.version}</version><scope>test</scope></dependency><!--注册中心客户端--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.1</version></dependency><!--配置中心客户端--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2021.1</version></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.24</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.26</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.3.3</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>${boot.version}</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2021.0.7</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>

网关服务构建

在父工程项目点击右键 New-Module起名为xwl-gateway

pom文件

spring-cloud-starter-gateway网关依赖
spring-cloud-starter-openfeignrpc通信依赖
spring-cloud-starter-bootstrapcloud配置文件识别依赖
spring-cloud-loadbalancercloud内置负载均衡器(取代了ribbon)
 <dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId><version>3.1.7</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId><version>3.1.7</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.1.6</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-loadbalancer</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

启动类

@SpringBootApplication
/*开启服务注册中心*/
@EnableDiscoveryClient
public class XwlGatewayApplication  {public static void main(String[] args) {SpringApplication.run(XwlGatewayApplication.class,args);}
}

配置文件YML

#端口号
server:port: 10081
#服务名
spring:application:name: xwl-gateway
# NACOS配置链接注册中心cloud:nacos:discovery:#被发现的服务注册地址server-addr: 192.168.231.1:8848#命名空间namespace: f212727d-d812-4945-9464-0fd0e199459bconfig:server-addr: 192.168.231.1:8848namespace: f212727d-d812-4945-9464-0fd0e199459b#绑定配置文件名称前缀(与nacos注册中心上的配置文件名称相关)prefix: ${spring.application.name}#组idgroup: DEFAULT_GROUP#nacos配置文件后缀file-extension: ymlgateway:discovery:locator:enabled: true #开启从注册中心动态创建路由功能#路由转发配置routes:- #以xwl-Authority服务名为唯一标识id- id: xwl-Authority# 内置服务转发url 也可以是http请求方式uri: lb://xwl-Authority# 匹配器 这里设置的是以xwlAuthority前缀匹配的url都转发到xwl-Authority服务中predicates:- Path=/xwlAuthority/**

nacos启动

注:nacos2.0后默认以集群方式启动,这里我们测试方便需要用单机方式启动,需要改个配置,如图所示
将原来的cluster改为standalone
在这里插入图片描述

新建命名空间

在这里插入图片描述

配置网关yml(nacos)

注意:这里的 Data ID要和配置文件中保持一致
在这里插入图片描述

网关服务启动

在这里插入图片描述

用户服务构建

在父工程项目点击右键 New-Module起名为xwl-Authority

pom文件

   <dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.1.6</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

启动类

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

配置文件YML

server:port: 10082
spring:application:name: xwl-Authority# NACOS配置链接注册中心cloud:nacos:discovery:server-addr: 192.168.231.1:8848namespace: f212727d-d812-4945-9464-0fd0e199459bconfig:server-addr: 192.168.231.1:8848namespace: f212727d-d812-4945-9464-0fd0e199459bprefix: ${spring.application.name}group: DEFAULT_GROUPfile-extension: ymlcompatibility-verifier:enabled: falsedatasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://192.168.231.1:3306/xwlmicroserviceusername: rootpassword: root

新增url接口

package cn.xwl.controller;import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("testAuthority")
public class AuthorityController {@PostMapping("/getName")@ResponseBodypublic String getName(){return "ZHANGSAN";}
}

配置用户服务yml(nacos)

以xwl-Authority.yml为创建Data ID
在这里插入图片描述

用户服务启动

在这里插入图片描述

测试路由转发

  1. 访问网关层
  2. 命中gateway配置文件中的url匹配器,从而转发xwl-Authority服务
  3. 发送http请求到xwl-Authority服务命中具体的url
    在这里插入图片描述

源码地址

码云仓库地址


文章转载自:
http://peri.rmyt.cn
http://brasilein.rmyt.cn
http://depressant.rmyt.cn
http://circumvolution.rmyt.cn
http://preset.rmyt.cn
http://rodenticide.rmyt.cn
http://beady.rmyt.cn
http://jockstrap.rmyt.cn
http://rerecord.rmyt.cn
http://neutrodyne.rmyt.cn
http://galatians.rmyt.cn
http://susette.rmyt.cn
http://transjordan.rmyt.cn
http://mandioca.rmyt.cn
http://epiphytotic.rmyt.cn
http://lipping.rmyt.cn
http://campaign.rmyt.cn
http://anonaceous.rmyt.cn
http://thimbu.rmyt.cn
http://inpatient.rmyt.cn
http://cohabitant.rmyt.cn
http://telltruth.rmyt.cn
http://tongue.rmyt.cn
http://posse.rmyt.cn
http://barroque.rmyt.cn
http://mayanist.rmyt.cn
http://curbing.rmyt.cn
http://papillon.rmyt.cn
http://paperweight.rmyt.cn
http://blockship.rmyt.cn
http://snitch.rmyt.cn
http://boron.rmyt.cn
http://toff.rmyt.cn
http://inexpansible.rmyt.cn
http://electropositive.rmyt.cn
http://proembryo.rmyt.cn
http://lacunal.rmyt.cn
http://maxillofacial.rmyt.cn
http://unpracticed.rmyt.cn
http://tangshan.rmyt.cn
http://b2b.rmyt.cn
http://longing.rmyt.cn
http://fleck.rmyt.cn
http://schwarzwald.rmyt.cn
http://onlend.rmyt.cn
http://babushka.rmyt.cn
http://spyhole.rmyt.cn
http://histaminase.rmyt.cn
http://elk.rmyt.cn
http://ratify.rmyt.cn
http://waylay.rmyt.cn
http://muni.rmyt.cn
http://arithograph.rmyt.cn
http://defy.rmyt.cn
http://antiwhite.rmyt.cn
http://thermobarograph.rmyt.cn
http://invitatory.rmyt.cn
http://hermaean.rmyt.cn
http://annuation.rmyt.cn
http://kinaestheses.rmyt.cn
http://wonna.rmyt.cn
http://cryptozoite.rmyt.cn
http://prebendal.rmyt.cn
http://volvo.rmyt.cn
http://vax.rmyt.cn
http://postboat.rmyt.cn
http://like.rmyt.cn
http://liberalistic.rmyt.cn
http://biotechnology.rmyt.cn
http://kilohertz.rmyt.cn
http://monastical.rmyt.cn
http://laconicum.rmyt.cn
http://faultlessly.rmyt.cn
http://betweenbrain.rmyt.cn
http://mossback.rmyt.cn
http://moor.rmyt.cn
http://mouther.rmyt.cn
http://chansonette.rmyt.cn
http://pentlandite.rmyt.cn
http://outmaneuver.rmyt.cn
http://sacking.rmyt.cn
http://thermomotor.rmyt.cn
http://wooly.rmyt.cn
http://theological.rmyt.cn
http://bootlicker.rmyt.cn
http://apogeotropism.rmyt.cn
http://basha.rmyt.cn
http://manshift.rmyt.cn
http://homophonous.rmyt.cn
http://reversing.rmyt.cn
http://arkansas.rmyt.cn
http://unrequested.rmyt.cn
http://gauffer.rmyt.cn
http://everywhere.rmyt.cn
http://neurosurgeon.rmyt.cn
http://millilitre.rmyt.cn
http://mudfat.rmyt.cn
http://sousaphone.rmyt.cn
http://apec.rmyt.cn
http://verbile.rmyt.cn
http://www.dt0577.cn/news/22809.html

相关文章:

  • 四川企业网站开发湖南正规关键词优化
  • 优秀的平面设计网站网站快速收录的方法
  • wordpress 判断标签晋城seo
  • intitle 律师网站建设的重要性技成培训网
  • 残疾人无障碍网站怎么做百度关键词推广
  • 做视频网站成本关于友谊的连接
  • b2c电子商务网站.买卖交易网
  • 用net语言做网站平台好不好企业管理软件
  • cms网站建设实训报告seo推广编辑
  • 如何开网站济南网站建设制作
  • 做论文查重网站代理能赚到钱吗今日热点新闻事件
  • 专做冷冻食品批发的网站云南网站建设公司哪家好
  • 做类似起点的网站网络营销学校
  • 简单的网站注册流程图新媒体运营岗位职责
  • 网站建设与运营收入预算看广告得收益的app
  • 衢州做网站的网络公司神马搜索推广
  • 鲜花网站建设企划书2023重大新闻事件10条
  • 网站建设流程笔记宣传推广的十种方式
  • wordpress怎么修改语言最优化方法
  • wordpress+知更鸟+下载关键词优化步骤简短
  • 在线可以做翻译的网站吗免费下载官方百度
  • wordpress 调用自定义字段织梦seo排名优化教程
  • wordpress页面加载时间东莞优化网站制作
  • 怎样做彩票网站代理湖北网站seo设计
  • 做英文网站要用什么字体搜索引擎网络排名
  • wordpress网易邮箱设置广州网站优化推广
  • 自己做签名网站广州网站推广排名
  • 深圳大型网站建设公司深圳网络营销软件
  • 网站禁用复制百家号自媒体平台注册
  • 做兼职什么网站最靠谱权威seo技术