✅P173_商城业务-检索服务-搭建页面环境
2024/2/13大约 1 分钟
1、引入thymeleaf依赖
cfmall-search/pom.xml
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>2、引入静态资源
将index.html引入到cfmall-search/src/main/resources/templates中,其余文件放到/mydata/nginx/html/static/search/下,


index.html导入thymeleaf的命名空间:xmlns:th="http://www.thymeleaf.org"
<html lang="en" xmlns:th="http://www.thymeleaf.org">注意放置到指定路径后,要Ctrl+F9加载下页面
3、页面修改
全文替换,注意图片1红框中路径
href="		
href="/static/search/
src="
src="/static/search/

5、修改 hosts 配置文件
hosts 文件路径:C:\Windows\System32\drivers\etc
在文件最后面追加以下内容:192.168.17.130 search.cfmall.com
6、修改 nginx 配置文件
vi /mydata/nginx/conf/conf.d/cfmall.conf

重启nginx:docker restart nginx
7、配置路由规则
cfmall-gateway/src/main/resources/application.yml
        - id: cfmall_host_route
          uri: lb://cfmall-product
          predicates:
            - Host=cfmall.com
            
	    - id: cfmall_search_route
          uri: lb://cfmall-search
          predicates:
            - Host=search.cfmall.com8、实现的转发效果
实现转发效果

测试
