使用若依微服务
关于nacos中配置
找到nacos/config目录下 修改如下配置
db.url.0=jdbc:mysql://lcoalhost:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=xxx
db.password=xxx
配置gateway
# 配置验证码开放,和白名单,xss
security:
captcha:
enabled: true
type: math
xss:
enabled: true
exclude-urls:
- /system/notice
ignore:
whites:
- /auth/logout
- /auth/login
- /*/v2/api-docs
- /csrf
# 配置网关路由和跨域
cloud:
# gateway-config
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOriginPatterns: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
exposedHeaders: "Content-Disposition,Content-Type,Cache-Control"
discovery:
locator:
enabled: true
lower-case-service-id: true
# routes-config
routes:
# 认证中心
- id: ruoyi-auth
uri: lb://ruoyi-auth
predicates:
- Path=/auth/**
filters:
# 验证码处理
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# 代码生成
- id: ruoyi-gen
uri: lb://ruoyi-gen
predicates:
- Path=/code/**
filters:
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# 定时任务
# - id: ruoyi-job
# uri: lb://ruoyi-job
# predicates:
# - Path=/schedule/**
# filters:
# - StripPrefix=1
# 系统模块
- id: ruoyi-system
uri: lb://ruoyi-system
predicates:
- Path=/system/**
filters:
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# 文件服务
# - id: ruoyi-file
# uri: lb://ruoyi-file
# predicates:
# - Path=/file/**
# filters:
# - StripPrefix=1
# # whaletest模块
# - id: ruoyi-whaletest
# uri: lb://ruoyi-whaletest
# predicates:
# - Path=/whaletest/**
# filters:
# - StripPrefix=1
配置system模块下的mybatis包映射和数据源
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
dynamic:
druid:
initial-size: 5
max-active: 20
datasource:
master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/tour-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: xxx
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.system
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
redis的配置文件
redis:
# 地址
host: xxxx
# 端口,默认为6379
port: xxxx
# 数据库索引
database: 0
# 密码
password: xxxx
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
username: 'default'
关于命名空间
bootstarp.yaml的namespace必须与nacos中的配置文件的data-Id相同。