内容管理模块
课程分类树状结构查询
递归和内连接(左连接)两种方式
媒资管理模块
nacos配置中心
详细内容见文档笔记
-
api模块引入了service模块,并且两个模块都进行了nacos配置。由于api模块应用了service模块,所以在api的bootstrp中必须用extension-configs扩展配置文件 的方式引用service工程所用到的配置文件
-
nacos提供了shared-configs可以引入公用配置。
在content-api中配置了swagger,所有的接口工程 都需要配置swagger,这里就可以将swagger的配置定义为一个公用配置,哪个项目用引入即可。进入nacos的开发环境,添加swagger-dev.yaml公用配置。项目使用shared-configs可以引入公用配置。在接口工程的本地配置文件 中引入公用配置,如下: -
配置示例
spring: application: name: content-api cloud: nacos: server-addr: 192.168.101.65:8848 discovery: namespace: dev group: xuecheng-plus-project config: namespace: dev group: xuecheng-plus-project file-extension: yaml refresh-enabled: true extension-configs: - data-id: content-service-${ spring.profiles.active}.yaml group: xuecheng-plus-project refresh: true shared-configs: - data-id: swagger-${ spring.profiles.active}.yaml group: xuecheng-plus-common refresh: true - data-id: logging-${ spring.profiles.active}.yaml group: xuecheng-plus-common refresh: true profiles: active: dev
-
nacos各配置文件 的优先级
项目应用名配置文件(nacos配置) > 扩展配置文件 > 共享配置文件 > 本地配置文件。
有时候我们在测试程序时直接在本地加一个配置进行测试,这时我们想让本地最优先,可以在nacos配置文件 中配置如下即可实现(nacos对应的项目应用名配置文件):#配置本地优先 spring: cloud: config: override-none: true
gateway
本项目主要用于路由转发
-
gateway本地bootstrap配置文件
spring: application: name: gateway cloud: nacos: server-addr: 192.168.101.65:8848 discovery: namespace: ${ spring.profiles.active} group: xuecheng-plus-project config: namespace: ${ spring.profiles.active} group: xuecheng-plus-project file-extension: yaml refresh-enabled: true shared-configs: - data-id: logging-${ spring.profiles.active}.yaml group: xuecheng-plus-common refresh: true profiles: active: dev
-
nacos中gateway的配置
server: port: 63010 # 网关端口 spring: cloud: gateway: # filter: # strip-prefix: # enabled: true routes: # 网关路由配置 - id: content-api # 路由id,自定义,只要唯一即可 # uri: http://127.0.0.1:8081 # 路由的目标地址 http就是固定地址 uri: lb://content-api # 路由的目标地址 lb就是负载均衡,后面跟服务名称 predicates: # 路由断言,也就是判断请求是否符合路由规则的条件 - Path=/content/** # 这个是按照路径匹配,只要以/content/开头就符合要求 # filters: # - StripPrefix=1 - id: system-api # uri: http://127.0.0.1:8081 uri: lb://system-api predicates: - Path=/system/** # filters: # - StripPrefix=1 - id: media-api # uri: http