搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
Li_阴宅
这个屌丝很懒,什么也没留下!
关注作者
热门标签
jquery
HTML
CSS
PHP
ASP
PYTHON
GO
AI
C
C++
C#
PHOTOSHOP
UNITY
iOS
android
vue
xml
爬虫
SEO
LINUX
WINDOWS
JAVA
MFC
CEF3
CAD
NODEJS
GIT
Pyppeteer
article
热门文章
1
GUI图形编程(6)---事件_图形交互 编程模型 事件
2
浅谈用二分和三分法解决问题(c++)_三分法c++
3
N2N(docker方式安装)实现远程访问家里群晖
4
Android可信执行环境TEE最全介绍_android tee
5
基于STM32的四种波形发生器控制设计_stm32输出可调频率幅值方波
6
Pandas的qcut()与cut()_pandas 如何由qcut 返回第几组
7
数字IC验证高频面试问题整理(附答案)_数字验证 面试
8
【linux】软件包安装pip/yum/apt_yum 安装pip
9
[精品毕设]微信小程序springboot居家养老服务+后台管理前后分离_springboot前后端分离 管理后台微信小程序
10
jwt ---- json web token_jsonwebtoken依赖
当前位置:
article
> 正文
2.微服务项目实战---环境搭建,实现电商中商品、订单、用户_springcloud 用户服务,订单服务,商品服务
作者:Li_阴宅 | 2024-08-11 16:44:09
赞
踩
springcloud 用户服务,订单服务,商品服务
使用的电商项目中的商品、订单、用户为案例进行讲解。
2.1
案例准备
2.1.1
技术选型
maven
:
3.3.9
数据库:
MySQL 5.7
持久层
: SpingData Jpa
其他
: SpringCloud Alibaba
技术栈
2.1.2
模块设计
springcloud-alibaba
父工程
shop-common
公共模块【实体类】
shop-user
用户微服务 【端口
: 807x
】
shop-product
商品微服务 【端口
: 808x
】
shop-order
订单微服务 【端口
: 809x
】
2.1.3
微服务调用
在微服务架构中,最常见的场景就是微服务之间的相互调用。我们以电商系统中常见的
用户下单
为
例来演示微服务的调用:客户向订单微服务发起一个下单的请求,在进行保存订单之前需要调用商品微服务查询商品的信息。
我们一般把服务的主动调用方称为
服务消费者
,把服务的被调用方称为
服务提供者
。
在这种场景下,订单微服务就是一个服务消费者, 商品微服务就是一个服务提供者。
2.2
创建父工程
创建一个
maven
工程,然后在
pom.xml
文件中添加下面内容
版本对应:
2.3
创建基础模块
1
创建
shop
-
common
模块,在
pom.xml
中添加依赖
2
创建实体类
2.4
创建用户微服务
步骤
:
1
创建模块 导入依赖
2
创建
SpringBoot
主类
3
加入配置文件
4
创建必要的接口和实现类
(controller service dao)
新建一个
shop
-
user
模块,然后进行下面操作
1
创建
pom.xml
2
编写主类
3
创建配置文件
2.5
创建商品微服务
1
创建一个名为
shop_product
的模块,并添加
springboot
依赖
2
创建工程的主类
3
创建配置文件
application.yml
4
创建
ProductDao
接口
p
5
创建
ProductService
接口和实现类
6
创建
Controller
7
启动工程,等到数据库表创建完毕之后,加入测试数据
8
通过浏览器访问服务
2.6
创建订单微服务
1
创建一个名为
shop
-
order
的模块
,
并添加
springboot
依赖
2
创建工程的主类
3
创建配置文件
application.yml
4
创建
OrderDao
接口
5
创建
OrderService
接口和实现类
6
创建
RestTemplate
7
创建
Controller
8
启动工程
,
通过浏览器访问服务进行测试
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/w/Li_阴宅/article/detail/965217
推荐阅读
article
SpringCloud
LoadBalancer
_
spring
-
cloud
-
loadbalancer
...
LoadBalancer
(负载均衡器)是一种网络设备或软件机制,用于分发传入的网络流量负载请求到多个后端目标服务器上,从...
赞
踩
article
微服务架构
--
springcloud
...
注册中心解压后打开bin下的starterup.cmd修改配置文件为单机模式
--
set MODE="standalon...
赞
踩
article
(二)
SpringCloud
+
Security
+
Oauth2
微
服务
初步集成_springcloud...
本文主要好介绍了
SpringCloud
+
Security
+
Oauth2
的初步集成,项目源码地址oauth2.0集成案例...
赞
踩
article
【
Spring
Cloud】
Spring
Security
简介
、
快速入门
、
原理
流程
_springclo...
简介
、
快速入门
、
登录校验
流程
、
原理初探
、
认证
流程
详解_
springcloud
security
springcloud
s...
赞
踩
article
(一) SpringCloud+
Security
+
Oauth2
微
服务
授权初步认识_springclo...
再前面的
security
专题中 我们学习了单体架构基于Spring
Security
实现的授权方案,这种在业务量较小及业务...
赞
踩
article
Spring
Cloud
整合
Spring
Security
认证鉴权【
Spring
Cloud
系列
6...
Spring
Cloud
大型
系列
课程正在制作中,欢迎大家关注与提意见。程序员每天的CV 与 板砖,也要知其所以然,本
系列
...
赞
踩
article
Springcloud
----
sleuth
+
zipkin
链路追踪_
java
-
jar
zipkin
-...
主要功能就是在分布式系统中提供追踪解决方案。它大量借用了GoogleDapper的设计, 先来了解一下Sleuth中的术...
赞
踩
article
黑马
程序员
微
服务
技术
栈教程 - 1.
SpringCloud
微
服务
治理_
黑马
微
服务
...
黑马
程序员
微
服务
技术
栈教程 - 1.
SpringCloud
微
服务
治理_
黑马
微
服务
黑马
微
服务
...
赞
踩
article
黑马
微
服务
springcloud
day
01
(
微
服务
介绍、
Eureka
)_黑马
微
服务
sprin...
微
服务
框架自动化部署
微
服务
技术栈。_黑马
微
服务
springcloud
day
黑马
微
服务
springcloud
d...
赞
踩
article
SpringCloud
入门 3:
config
实现
配置
中
心
,自动刷新,讲
配置
中
心
注册到
Eureka
中
...
简介Spring Cloud Config 是 Spring Cloud 家族
中
最早的
配置
中
心
,虽然后来又发布了 Con...
赞
踩
article
spring
c
lo
ud
eureka多网卡多IP设置_
spring
.
c
lo
ud
.
inetutils
....
1.版本
spring
c
lo
ud
:Hoxton.SR8
spring
boot:2.3.3.RELEASE2.
spring
cl...
赞
踩
article
SpringCloud
Eureka
多
网卡
配置
_
euraka
配置
指定
网卡
...
多
网卡
环境下
Eureka
服务注册IP选择。_
euraka
配置
指定
网卡
euraka
配置
指定
网卡
...
赞
踩
article
SpringCloud
Security
安全认证_
security
.
enable
...
1、加入jar
org.springframework.boot[详细]
-->
赞
踩
article
SpringCloud
Eureka
参数
配置
项详解...
Eureka
涉及到的参数
配置
项数量众多,它的很多功能都是通过参数
配置
来实现的,了解这些参数的含义有助于我们更好的应用Eu...
赞
踩
article
SpringCloud
-
Eureka
快速入门,集群搭建_
eureka
-
server
监控
页面
...
个人主页:https://blog.csdn.net/hello_list?type=blog前言这里博主从说更新spr...
赞
踩
article
Springcloud(1)
SpringCloud
搭建
Eureka
集群
_
springcloud
eu...
搭建
Eureka
集群
搭建
Eureka
注册中心
集群
说明:网上的基本是使用本地改Host文件来
搭建
多个虚拟域名指向本机。先使...
赞
踩
article
【SpringCloud 2
0
21.
0
.
0
】5、
Eureka
构建过程:
Server
\
Client
配...
1、构建步骤1)
eurek
a-server(1)创建Meven工程
spring
cloud
-
eurek
a-7
0
0
1(2)导...
赞
踩
article
SpringCloud
(四):
Eureka
集群
_
eureka
默认
集群
方式...
什么是
集群
:不同的服务器上运行一个相同的服务,而这些服务器群体,对外作一个超大运算的整体。作用:高可用,其中一台机器宕机...
赞
踩
article
Springboot
&
Springcloud
框架
_
springboot
+
springcloud
...
1、什么
是
Spring Boot?Spring Boot
是
Spring 开源组织下的子项目,
是
Spring 组件...
赞
踩
article
SpringCloud
-微
服务
入门之统一
配置
中心
Config
(5)_
springcloud
提取公共配...
要做好微
服务
的
配置
管理,则需要处理好以下几个问题:
SpringCloud
Config
核心就是
配置
中心
,通过一个
服务
端和...
赞
踩
相关标签
spring cloud
spring
后端
java
负载均衡
LoadBalancer
架构
微服务
spring boot
nacos
eureka