目录

一、SpringBoot整合MybatisPlus

创建自动生成代码子模块

1、基于maven方式创建子模块zmall-generator,用于结合mybatis-plus生成代码。

创建商品服务子模块

1.基于Spring Initializr方式创建商品服务模块zmall-product

2.在主模块pom.xml中加入商品服务子模块zmall-product

3.配置商品服务子模块zmall-product的application.yml配置文件

4.在商品服务子模块中启动类上添加

5.将公共子模块中生成的service层代码复制到商品服务子模块zmall-product中,并删除掉非商品相关的service接口及实现类

6.创建junit实现接口测试

二、SpringBoot整合Freeamarker

1.在公共模块zmall-common中引入freemarker依赖

2.在商品子模块zmall-product中添加首页和商品详情页面及公共资源(js/css/images)

3.创建ProductController定义请求方法

​编辑4.在index.html中绑定热门数据和product.html中绑定商品详情数据

三、SpringBoot整合微服务&gateway&nginx

整合微服务之商品服务zmall-product

创建并配置网关gateway服务

1.基于Spring initializr方式创建网关模块zmall-gateway

2.配置pom.xml添加nacos和gateway的依赖

3.修改启动类,向nacos进行注册

4.配置application.yml设置gateway路由转发规则

5.将易买网网页素材中的公共静态资源js/css/images复制到gateway网关服务中

安装配置Windows版nginx

1.先将Nginx压缩包放到非中文目录进行解压

如果出现IIS7,那么cmd窗口中执行下列指令

2.进入conf目录,并修改nginx.conf配置文件

安装配置SwitchHosts

1.直接双击exe文件即可安装SwitchHosts

2.打开SwitchHosts设置一级域名

请求链路测试

单独访问商品服务:http://localhost:8020/index.html

通过gateway访问:http://localhost:8000/product-serv/index.htm

通过nginx访问:http://zmall.com/product-serv/index.html ​


一、SpringBoot整合MybatisPlus

创建自动生成代码子模块

专门用于Mybatis代码生成的模块

1、基于maven方式创建子模块zmall-generator,用于结合mybatis-plus生成代码。

 1.在公共模块zmall-common中注释掉mybatis的依赖引入,改换成mybatis-plus依赖引入

     <!-- mybatis plus依赖 --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.0</version></dependency>

2.在zmall-generator中引入mybatis-plus-generator依赖。该模块专用于mybatis-plus的代码生成,所以单独在此引入该依赖即可。

<dependency><groupId>com.zking.zmall</groupId><artifactId>zmall-common</artifactId><version>1.0-SNAPSHOT</version>
</dependency>
<!-- mybatis-plus-generator依赖 -->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>3.4.0</version>
</dependency>

3.在src/main/resources下创建templates目录,并导入mybatis-generator生成代码模板页

导入文件

4.在src/main/java下创建包com.zking.zmall,并导入generator下的CodeGenerator类用于代码生成

5.修改CodeGenerator类基本生成参数,并生成代码

package com.zking.zmall;import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;public class CodeGenerator {//数据库连接参数public static String driver = "com.mysql.jdbc.Driver";public static String url = "jdbc:mysql://localhost:3306/zmall?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true";public static String username="root";public static String password="123";//父级别包名称public static String parentPackage = "com.zking.zmall";//项目名设置(如果是SpringCloud项目则需要设置,其他为""即可)public static String projectName="/zmall-generator";//代码生成的目标路径public static String generateTo = "/src/main/java";//mapper.xml的生成路径public static String mapperXmlPath = "/src/main/resources/mapper";//控制器的公共基类,用于抽象控制器的公共方法,null值表示没有父类public static String baseControllerClassName ;//业务层的公共基类,用于抽象公共方法public static String baseServiceClassName ;//作者名public static String author = "zking";//模块名称,用于组成包名public static String modelName = "model";/*** <p>* 读取控制台内容* </p>*/public static String scanner(String tip) {Scanner scanner = new Scanner(System.in);StringBuilder help = new StringBuilder();help.append("请输入" + tip + ":");System.out.println(help.toString());if (scanner.hasNext()) {String ipt = scanner.next();if (StringUtils.isNotBlank(ipt)) {return ipt;}}throw new MybatisPlusException("请输入正确的" + tip + "!");}public static void main(String[] args) {// 代码生成器AutoGenerator mpg = new AutoGenerator();// 全局配置GlobalConfig gc = new GlobalConfig();//设置代码输出目录String projectPath = System.getProperty("user.dir");gc.setOutputDir(projectPath + projectName + generateTo);//作者gc.setAuthor(author);//设置时间类型为Dategc.setDateType(DateType.TIME_PACK);gc.setOpen(false);//设置Mapper.xml的BaseColumnListgc.setBaseColumnList(true);//设置Mapper.xml的BaseResultMapgc.setBaseResultMap(true);// 设置实体属性 Swagger2 注解// gc.setSwagger2(true);mpg.setGlobalConfig(gc);// 数据源配置DataSourceConfig dsc = new DataSourceConfig();dsc.setUrl(url);dsc.setDriverName(driver);dsc.setUsername(username);dsc.setPassword(password);mpg.setDataSource(dsc);// 包配置PackageConfig pc = new PackageConfig();//pc.setModuleName(scanner("模块名"));pc.setParent(parentPackage);//设置包名pc.setEntity(modelName);mpg.setPackageInfo(pc);// 自定义配置InjectionConfig cfg = new InjectionConfig() {@Overridepublic void initMap() {// to do nothing}};// 如果模板引擎是 freemarkerString templatePath = "/templates/mybatis-generator/mapper2.xml.ftl";// 如果模板引擎是 velocity// String templatePath = "/templates/mapper.xml.vm";// 自定义输出配置List<FileOutConfig> focList = new ArrayList<>();// 自定义配置会被优先输出focList.add(new FileOutConfig(templatePath) {@Overridepublic String outputFile(TableInfo tableInfo) {// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!return projectPath + projectName + mapperXmlPath + pc.getModuleName()+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;}});cfg.setFileOutConfigList(focList);mpg.setCfg(cfg);// 配置模板TemplateConfig templateConfig = new TemplateConfig();// 配置自定义输出模板//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别templateConfig.setMapper("templates/mybatis-generator/mapper2.java");templateConfig.setEntity("templates/mybatis-generator/entity2.java");templateConfig.setService("templates/mybatis-generator/service2.java");templateConfig.setServiceImpl("templates/mybatis-generator/serviceImpl2.java");templateConfig.setController("templates/mybatis-generator/controller2.java");templateConfig.setXml(null);mpg.setTemplate(templateConfig);// 策略配置StrategyConfig strategy = new StrategyConfig();strategy.setNaming(NamingStrategy.underline_to_camel);strategy.setColumnNaming(NamingStrategy.underline_to_camel);strategy.setEntityLombokModel(true);strategy.setRestControllerStyle(true);strategy.setEntitySerialVersionUID(false);//设置controller的父类if (baseControllerClassName!=null) strategy.setSuperControllerClass(baseControllerClassName);//设置服务类的父类if (baseServiceClassName !=null ) strategy.setSuperServiceImplClass(baseServiceClassName);// 写于父类中的公共字段//strategy.setSuperEntityColumns("id");strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));strategy.setControllerMappingHyphenStyle(true);strategy.setTablePrefix("t_","zmall_");mpg.setStrategy(strategy);mpg.setTemplateEngine(new FreemarkerTemplateEngine());mpg.execute();}
}

 生成代码

此时运行可能会报错,有个包没有

我们需要将父工程的pom重新编译一下,先清除jar包

 再重新编译

完事之后我们再重新生成代码

注意:

  • 修改数据库连接URL中的数据库名、数据库账号和密码;

  • 修改父级别包名称

  • 修改项目名,如果是SpringCloud项目则修改,不是则默认“”

先生成

zmall_product_category,zmall_product

可以看到,已经生成完成了

但是有些接口类都需要放到对应的微服务里面去,以及其他类需要放到公共服务里去,我们再创建服务

创建商品服务子模块

1.基于Spring Initializr方式创建商品服务模块zmall-product

2.在主模块pom.xml中加入商品服务子模块zmall-product

<modules><module>zmall-common</module><module>zmall-user</module><module>zmall-generator</module><module>zmall-product</module>
</modules>

再将商品服务pom更改,参照用户服务就行

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 父模块 --><parent><groupId>com.zking.zmall</groupId><artifactId>zmall</artifactId><version>1.0-SNAPSHOT</version></parent><artifactId>zmall-product</artifactId><dependencies><dependency><groupId>com.zking.zmall</groupId><artifactId>zmall-common</artifactId><version>1.0-SNAPSHOT</version></dependency></dependencies></project>

3.配置商品服务子模块zmall-product的application.yml配置文件

server:port: 8020
spring:application:name: zmall-productdatasource:#type连接池类型 DBCP,C3P0,Hikari,Druid,默认为Hikaritype: com.zaxxer.hikari.HikariDataSourcedriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://localhost:3306/zmall?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=trueusername: rootpassword: 123freemarker:suffix: .htmltemplate-loader-path: classpath:/templates/
#mybatis-plus配置
mybatis-plus:#所对应的 XML 文件位置mapper-locations: classpath*:/mapper/*Mapper.xml#别名包扫描路径type-aliases-package: com.zking.zmall.modelconfiguration:#驼峰命名规则map-underscore-to-camel-case: true
#日志配置
logging:level:com.zking.zmall.mapper: debug

4.在商品服务子模块中启动类上添加

重新编译

先将mapper和model拷贝到common中 编译之后就有了

编译成功后,将service拷到商品微服务这里来,再将上面的mapper,model,controller与service删掉不要了

加这些的目的是为了启动时能扫描到

@SpringBootApplication
@MapperScan({"com.zking.zmall.mapper"})
public class ZmallProductApplication {public static void main(String[] args) {SpringApplication.run(ZmallProductApplication.class, args);}
}

5.将公共子模块中生成的service层代码复制到商品服务子模块zmall-product中,并删除掉非商品相关的service接口及实现类

这一步在第四步为了铺垫已经做完了。

6.创建junit实现接口测试

zmall-common模块

<!--        用于test目录下的测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency>

再添加测试类

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ProductServiceImplTest {@Autowiredprivate IProductService productService;@Beforepublic void setUp() throws Exception {}@Afterpublic void tearDown() throws Exception {}@Testpublic void queryProduct() {List<Product> list = productService.list();list.forEach(System.out::println);}
}

测试一下 测试成功

二、SpringBoot整合Freeamarker

1.在公共模块zmall-common中引入freemarker依赖

        <!-- 用于页面展示,集成模板引擎--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId></dependency>

2.在商品子模块zmall-product中添加首页和商品详情页面及公共资源(js/css/images)

将zmall-user中的静态资源添加到zmall-product中

将zmall-product中login.html删掉

将资料目录中的易买网网页素材中的Index.html(易买网主页)、Product.html(商品详情页)添加到项目的templates和static目录下,最好请将Index.html、Product.html页面首字母改成小写

将页面中的头部申明<!DOCTYPE html ....>修改成<!DOCTYPE html>(支持H5风格)、在页面中通过<#include>指令引入common目录中的head.html

3.创建ProductController定义请求方法

@Controller
public class ProductController {@Autowiredprivate IProductService productService;@RequestMapping("/index.html")public String index(Model model){//按照商品的销量降序排序获取销量排名Top5的商品List<Product> products = productService.list(new QueryWrapper<Product>().orderByDesc("hot").last("limit 5"));model.addAttribute("hots",products);return "index";}@RequestMapping("/product.html")public String detail(Model model,Integer pid){//根据商品ID查询商品详情信息Product product = productService.getById(pid);model.addAttribute("product",product);return "product";}
}

我们先访问一下,看能否访问的到

启动zmall-product项目 此时访问index.html是会报错的,因为我们没有c标签,将c标签注释掉

可以看见,我们已经成功访问到了。

4.在index.html中绑定热门数据和product.html中绑定商品详情数据

index.html中绑定热门数据:

我们刚刚访问的数据都是si数据,所有我们需要将数据变"活"

index.html中找到数据所在地

 将后台所查询到的数据绑定到这里

修改后的代码

<ul class="featureUL"><#--判断hots是否为空--><#if hots??><#--循环遍历热销商品--><#list hots as it><li class="featureBox"><div class="box"><div class="h_icon"><img src="data:images/hot.png" width="50" height="50" /></div><div class="imgbg"><a href="../product.html?pid=${(it.id)!}"><img src="${(it.fileName)!}" width="160" height="136" /></a></div><div class="name"><a href="../product.html?pid=${(it.id)!}"><#-- <h2>德国进口</h2>-->${(it.name)!}</a></div><div class="price"><font>¥<span>${(it.price)!}</span></font> &nbsp; 26R</div></div></li></#list></#if></ul>

重新运行项目,数据已经改变了(数据没对上是因为数据库的演示数据,没有修改)

product.html中绑定商品详情数据

这里也是一样,访问的数据也是si数据,所有我们也需要将数据变"活"

接下来修改product.html中的代码

<div class="content"><div id="tsShopContainer"><div id="tsImgS"><a href="${(product.fileName)!}" title="Images" class="MagicZoom" id="MagicZoom"><img src="${(product.fileName)!}" width="390" height="390" /></a></div><div id="tsPicContainer"><div id="tsImgSArrL" onclick="tsScrollArrLeft()"></div><div id="tsImgSCon"><ul><li onclick="showPic(0)" rel="MagicZoom" class="tsSelectImg"><img src="data:images/ps1.jpg" tsImgS="images/ps1.jpg" width="79" height="79" /></li><li onclick="showPic(1)" rel="MagicZoom"><img src="data:images/ps2.jpg" tsImgS="images/ps2.jpg" width="79" height="79" /></li><li onclick="showPic(2)" rel="MagicZoom"><img src="data:images/ps3.jpg" tsImgS="images/ps3.jpg" width="79" height="79" /></li><li onclick="showPic(3)" rel="MagicZoom"><img src="data:images/ps4.jpg" tsImgS="images/ps4.jpg" width="79" height="79" /></li><li onclick="showPic(4)" rel="MagicZoom"><img src="data:images/ps1.jpg" tsImgS="images/ps1.jpg" width="79" height="79" /></li><li onclick="showPic(5)" rel="MagicZoom"><img src="data:images/ps2.jpg" tsImgS="images/ps2.jpg" width="79" height="79" /></li><li onclick="showPic(6)" rel="MagicZoom"><img src="data:images/ps3.jpg" tsImgS="images/ps3.jpg" width="79" height="79" /></li><li onclick="showPic(7)" rel="MagicZoom"><img src="data:images/ps4.jpg" tsImgS="images/ps4.jpg" width="79" height="79" /></li></ul></div><div id="tsImgSArrR" onclick="tsScrollArrRight()"></div></div><img class="MagicZoomLoading" width="16" height="16" src="data:images/loading.gif" alt="Loading..." /></div><div class="pro_des"><div class="des_name"><p>${(product.name)!}</p>“开业巨惠,北京专柜直供”,不光低价,“真”才靠谱!</div><div class="des_price">本店价格:<b>¥${(product.price)}</b><br />消费积分:<span>28R</span></div><div class="des_choice"><span class="fl">型号选择:</span><ul><li class="checked">30ml<div class="ch_img"></div></li><li>50ml<div class="ch_img"></div></li><li>100ml<div class="ch_img"></div></li></ul></div><div class="des_choice"><span class="fl">颜色选择:</span><ul><li>红色<div class="ch_img"></div></li><li class="checked">白色<div class="ch_img"></div></li><li>黑色<div class="ch_img"></div></li></ul></div><div class="des_share"><div class="d_sh">分享<div class="d_sh_bg"><a href="#"><img src="data:images/sh_1.gif" /></a><a href="#"><img src="data:images/sh_2.gif" /></a><a href="#"><img src="data:images/sh_3.gif" /></a><a href="#"><img src="data:images/sh_4.gif" /></a><a href="#"><img src="data:images/sh_5.gif" /></a></div></div><div class="d_care"><a onclick="ShowDiv('MyDiv','fade')">关注商品</a></div></div><div class="des_join"><div class="j_nums"><input type="text" value="1" name="" class="n_ipt" /><input type="button" value="" onclick="addUpdate(jq(this));" class="n_btn_1" /><input type="button" value="" onclick="jianUpdate(jq(this));" class="n_btn_2" /></div><span class="fl"><a onclick="ShowDiv_1('MyDiv1','fade1')"><img src="data:images/j_car.png" /></a></span></div></div><div class="s_brand"><div class="s_brand_img"><img src="data:images/sbrand.jpg" width="188" height="132" /></div><div class="s_brand_c"><a href="#">进入品牌专区</a></div></div></div>

效果图

三、SpringBoot整合微服务&gateway&nginx

请求链路要求:客户端发送请求先经过nginx,再用nginx转至内部访问网关gateway,最后由网关服务的路由规则转发到微服务的内部服务。

整合微服务之商品服务zmall-product

在公共模块zmall-common中导入微服务相关依赖

<!--nacos客户端-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency><!--fegin组件-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency><!--nacos配置中心-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

先将Nacos打开

如果没有这个快捷方式的话,在Nacos的文件夹内写一个以.bat结尾的文件,文件中写入以下代码保存,再发送到桌面快捷方式就行了。

打开之后访问地址

将注册中心准备好了之后就添加配置

配置商品服务模块zmall-product的application.yml文件

  cloud:nacos:discovery:server-addr: localhost:8848

修改启动类,向nacos进行注册

@EnableDiscoveryClient
@SpringBootApplication
@MapperScan({"com.zking.zmall.mapper"})
public class ZmallProductApplication {public static void main(String[] args) {SpringApplication.run(ZmallProductApplication.class, args);}
}

现在商品微服务已经可以向注册中心进行注册,我们再启动刷新一下就能看见

创建并配置网关gateway服务

1.基于Spring initializr方式创建网关模块zmall-gateway

2.配置pom.xml添加nacos和gateway的依赖

先修改zmall-gateway中的pom,改成下图这样

再添加nacos和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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 父模块 --><parent><groupId>com.zking.zmall</groupId><artifactId>zmall</artifactId><version>1.0-SNAPSHOT</version></parent><artifactId>zmall-gateway</artifactId><dependencies><!--gateway 注意 此模式不能引入starter-web --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--nacos客户端--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency></dependencies>
</project>

在主模块pom中添加zmall-gateway

再将test文件删除掉

老样子,在主模块pom里重新编译

3.修改启动类,向nacos进行注册

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

4.配置application.yml设置gateway路由转发规则

server:port: 8000
spring:application:name: zmall-gateway #在注册中心的名字cloud:nacos:discovery:server-addr: localhost:8848 #往哪个注册中心注册gateway:routes:- id: product_route #路由的id,每个微服务都不一样uri: lb://zmall-product # lb指的是从nacos中按照名称获取微服务,并遵循负载均衡策略,因为一个微服务可能有不同的节点predicates:- Path=/product-serv/** #路由规则:如:从网关访问到商品微服务,都需要加一个前缀,可以加多层filters:- StripPrefix=1 #加几层

5.将易买网网页素材中的公共静态资源js/css/images复制到gateway网关服务中

这里请注意了,之前在商品服务模块zmall-product中已经配置了易买网的静态资源,为什么还要在gateway网关服务中再配置一次呢?这是因为当请求经过gateway网关服务后会进行断言条件匹配和条件路径截取等操作,从而导致gateway网关路由转发后静态资源失效404的问题,所以特此在gateway网关服务中也配置一次易买网网页素材中的公共静态资源js/css/images,确保能正常访问。

没有复制进来的效果:

尝试访问之后,发现就可以访问了,但是没有样式

解决方案:使用nginx动静分离方式实现,小编将会在下一遍文章所使用

配置静态资源访问服务器,将各个微服务模块中的静态访问资源迁移到静态资源访问服务器中,然后通过http方式访问即可。

复制进来后启动:

安装配置Windows版nginx

1.先将Nginx压缩包放到非中文目录进行解压

浏览器输入localhost,先查看是否正常启动,如出现下图就是正常的

如果出现IIS7,那么cmd窗口中执行下列指令

net stop w3svc

2.进入conf目录,并修改nginx.conf配置文件

先打开任务管理器,将刚刚测试的Nginx进程关掉(可能会出现没关掉的情况,建议多进几次查看)

关闭之后我们修改nginx.conf配置,将网关配置到Nginx配置文件中

server
{listen 80;server_name zmall.com;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;location / {proxy_pass http://127.0.0.1:8000/;}
}

将所选的删除,换成上方自己的配置

但是这里又遇到了一个问题,我们在网站上输入网址,不会输入localhost这种东西的,一般都是像baidu.com、jd.com那种的吧。我们可以使用这款工具(可以私信小编找我要的哈哈)

安装配置SwitchHosts

1.直接双击exe文件即可安装SwitchHosts

将它安装到非中文目录中,傻瓜式安装就行

进入文件

2.打开SwitchHosts设置一级域名

 编辑一级域名

如同百度,有很多二级域名,我们也可以配置二级域名

配置好了之后在Nginx配置文件中就能对应的上了,再启动Nginx进行测试

请求链路测试

单独访问商品服务:http://localhost:8020/index.html

通过gateway访问:http://localhost:8000/product-serv/index.htm

通过nginx访问:http://zmall.com/product-serv/index.html 

微服务项目实战-易买网网页(电商)二、MybatisPlus与微服务注册相关推荐

  1. 微服务项目实战-易买网网页(电商)一、项目框架及多模块开发

    本项目会被分为多个文章去讲解实现 目录 1.项目简介 项目模式 1.B2B模式 B2B (Business to Business) 2.B2C 模式 B2C (Business to Consume ...

  2. 【项目实战经验】电商系统常用数据结构

    查看全文 http://www.taodudu.cc/news/show-5356572.html 相关文章: android电商评论,三步教你获取电商评论数据 黑马Vue电商 电商数据仓库理论 ja ...

  3. Java生鲜电商平台-秒杀系统微服务架构设计与源码解析实战

    Java生鲜电商平台-秒杀系统微服务架构设计与源码解析实战 Java生鲜电商平台-  什么是秒杀 通俗一点讲就是网络商家为促销等目的组织的网上限时抢购活动 比如说京东秒杀,就是一种定时定量秒杀,在规定 ...

  4. 【.net core】电商平台升级之微服务架构应用实战

    一.前言 这篇文章本来是继续分享IdentityServer4 的相关文章,由于之前有博友问我关于微服务相关的问题,我就先跳过IdentityServer4的分享,进行微服务相关的技术学习和分享.微服 ...

  5. JAVA Mall 项目致力于打造一个完整的电商系统,采用微服务架构设计

    项目介绍 mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署.前台商城系统包含首页门户.商品推荐.商品搜索.商品展示. ...

  6. Java生鲜电商平台-深入理解微服务SpringCloud各个组件的关联与架构

    Java生鲜电商平台-深入理解微服务SpringCloud各个组件的关联与架构 概述 毫无疑问,Spring Cloud是目前微服务架构领域的翘楚,无数的书籍博客都在讲解这个技术.不过大多数讲解还停留 ...

  7. Spring Cloud Alibaba 大型微服务项目实战

    作者介绍 程序员十三,多年一线开发经验,历任高级开发工程师.后端主程.技术部门主管等职位.同时也是开源项目的爱好者和贡献者.掘金优秀作者.CSDN 博客专家.实体图书作者.专栏作者.视频讲师. 小册介 ...

  8. 电商网站模板_微购物商城网站建设:要做好这6点!

    随着互联网电商的发展,微购物商城也开始流行起来.这种商城网站可以避免商家被电商平台抽佣,商家自己也无需缴纳高额推广费,可以节约不少成本.如何做好一个购物商城网站?至少要保证这几点: 1.用美观的建站系 ...

  9. 实战分布式之电商高并发秒杀场景总览

    前言 本文是新系列"实战高并发"的开篇作.这个系列作为"我说分布式"的子系列,将着重挑选若干典型的分布式实战场景,尽量对当下高并发领域较为热门的架构及业务场景做 ...

最新文章

  1. R语言plotly可视化:plotly可视化分组归一化直方图(historgram)并在直方图中添加密度曲线kde、并在直方图的底部部边缘使用geom_rug函数添加边缘轴须图
  2. vs code中文乱码解决方法
  3. 操作系统课程设计--使用多线程模拟时间片轮转法调度
  4. JavaScript将成为浏览器战争的主战场
  5. Java笔记-重写JsonSerializer中serialize方法使Json中时间戳/1000
  6. OpenCV辅助对象(help objects)(6)_InputArray和OutputArray
  7. 小米:近期发现5件恶意抢注批量申请Redmi商标事件
  8. webpack插件配置(二)- HtmlWebpackPlugin
  9. Fiddler4——手机抓包
  10. PostGIS导入shp数据
  11. 用户使用计算机首要考虑因素,工业设计心理学试题(新整理有答案参考)
  12. 2009年9月手机搜索热门关键词排行榜
  13. 鸿蒙os基带版本,华为推出基于鸿蒙OS的Hi3861开发板
  14. 【题解】LuoGu5423:[USACO19OPEN]Valleys P
  15. DMP 数据管理平台极简教程 ( Data Management Platform )
  16. 微软新搜索引擎Bing探秘(组图)
  17. 阿里云ACP云计算错题集101-120
  18. Latex论文排版——图片
  19. AlphaFold2源码解析(9)--模型之损失
  20. OPENCV入门教程九:图像旋转任意角度

热门文章

  1. 自学Redis技术,如何在Java应用
  2. 华为鸿蒙系统界面清新,华为鸿蒙系统:全新UI界面
  3. Nuxt.js框架启动报错✖ 224 problems (146 errors, 78 warnings) 146 errors and 74 warnings potentially fixab
  4. 【重装系统】Ubuntu系统重装为windows10
  5. VS2010 Ultimate 微软官网免费下载 VS2010终级版
  6. 微信小程序—写字板、手写签名(高仿毛笔效果)让汉字引领世界
  7. 基本磁盘与动态磁盘 RAID磁盘冗余阵列区分(简单了解各种卷组)
  8. 力扣121题 “买卖股票的最 佳时机”
  9. 阿里企业邮箱的POP地址
  10. Spring Boot 整合 Spring Data JPA