三 配置文件sdgt_parent com.baiyee 0.0.1-SNAPSHOT 4.0.0 service_gatewayorg.springframework.cloud spring-cloud-starter-gatewaycom.alibaba.cloud spring-cloud-starter-alibaba-nacos-discoveryorg.springframework.boot spring-boot-maven-pluginsrc/main/java ***.properties ***.yml ***.xml false
# 服务端口
server.port=8080
# 服务名
spring.application.name=service-gateway
# nacos服务地址
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#使用服务发现路由
spring.cloud.gateway.discovery.locator.enabled=true
#设置路由id
spring.cloud.gateway.routes[0].id=service-cmn
#设置路由的uri
spring.cloud.gateway.routes[0].uri=lb://service-cmn
#设置路由断言,代理servicerId为auth-service的/auth/路径
spring.cloud.gateway.routes[0].predicates= Path=/admin/cmn/**
#设置路由id
spring.cloud.gateway.routes[1].id=service-obj
#设置路由的uri
spring.cloud.gateway.routes[1].uri=lb://service-obj
#设置路由断言,代理servicerId为auth-service的/auth/路径
spring.cloud.gateway.routes[1].predicates= Path=/admin/**
四 创建启动类
package com.baiyee.sdgt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ServerGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ServerGatewayApplication.class, args);
}
}
五 启动后
六 改造前端
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
//base_API: '"http://localhost:8201"', // 医院、商业公司、药房和任务分配的接口
// base_API: '"http://localhost:8202"', // 数据字典
//base_API: '"http://localhost:9001"', // nginx
// base_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
base_API: '"http://localhost:8080"'
})
七 测试
所有页面都可以正常显示



