【大型电商项目开发】商城业务-检索服务-搭建页面环境-47

导读:本篇文章讲解 【大型电商项目开发】商城业务-检索服务-搭建页面环境-47,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

一:搭建检索服务

1.在search包下的pom文件引入themeleaf模板

<!--引入thymeleaf模板引擎-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

2.引入静态页面

在这里插入图片描述

3.在服务器引入静态资源

cd  /mydata/nginx/html/static     #进入static文件夹
mkdir search   #新建search包

4.配置gulimail.conf文件

cd /mydata/nginx/conf/conf.d #进入到conf.d文件夹
vi gulimail.conf #编辑文件

server {
    listen       81;
    server_name  gulimail.com *.gulimail.com;
}

5.配置网关

spring:
  cloud:
    gateway:
      routes:
        - id: gulimail_search_route
            uri: lb://gulimail-search
            predicates:
              - Host=search.gulimail.com

在这里插入图片描述

6.检索服务首页回显

在这里插入图片描述

二:调整页面跳转

1.加上热启动配置文件

    <!--热启动配置文件-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

2.关闭themeleaf缓存

# 关闭thymeleaf缓存
spring.thymeleaf.cache=false

3.在controller包下新建SearchController类

    @GetMapping("/list.html")
    public String listPage(){
        return "list";
    }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/84101.html

(0)
小半的头像小半

相关推荐

极客之家——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!