update 重构 将系统内置配置放置到common包内独立加载 不允许用户随意修改
parent
3284b8707a
commit
8d675b0c21
|
|
@ -16,43 +16,20 @@ server:
|
|||
|
||||
dubbo:
|
||||
application:
|
||||
logger: slf4j
|
||||
# 元数据中心 local 本地 remote 远程 这里使用远程便于其他服务获取
|
||||
metadataType: remote
|
||||
# 可选值 interface、instance、all,默认是 all,即接口级地址、应用级地址都注册
|
||||
register-mode: instance
|
||||
service-discovery:
|
||||
# FORCE_INTERFACE,只消费接口级地址,如无地址则报错,单订阅 2.x 地址
|
||||
# APPLICATION_FIRST,智能决策接口级/应用级地址,双订阅
|
||||
# FORCE_APPLICATION,只消费应用级地址,如无地址则报错,单订阅 3.x 地址
|
||||
migration: FORCE_APPLICATION
|
||||
# 关闭qos端口避免单机多生产者端口冲突 如需使用自行开启
|
||||
qos-enable: false
|
||||
protocol:
|
||||
# 设置为 tri 即可使用 Triple 3.0 新协议
|
||||
# 性能对比 dubbo 协议并没有提升 但基于 http2 用于多语言异构等 http 交互场景
|
||||
# 如需使用 Triple 3.0 新协议 可查看官方文档
|
||||
# 使用 dubbo 协议通信
|
||||
name: dubbo
|
||||
# dubbo 协议端口(-1表示自增端口,从20880开始)
|
||||
port: -1
|
||||
# 指定dubbo协议注册ip
|
||||
# host: 192.168.0.100
|
||||
# 注册中心配置
|
||||
registry:
|
||||
address: nacos://${spring.cloud.nacos.server-addr}
|
||||
group: DUBBO_GROUP
|
||||
parameters:
|
||||
namespace: ${spring.profiles.active}
|
||||
# 消费者相关配置
|
||||
consumer:
|
||||
# 结果缓存(LRU算法)
|
||||
# 会有数据不一致问题 建议在注解局部开启
|
||||
cache: false
|
||||
# 支持校验注解
|
||||
validation: true
|
||||
# 超时时间
|
||||
timeout: 3000
|
||||
# 初始化检查
|
||||
check: false
|
||||
scan:
|
||||
# 接口实现类扫描
|
||||
base-packages: org.dromara.**.dubbo
|
||||
|
|
@ -170,24 +147,16 @@ logging:
|
|||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: Authorization
|
||||
# token有效期 设为一天 (必定过期) 单位: 秒
|
||||
timeout: 86400
|
||||
# token临时有效期 (指定时间无操作就过期) 单位: 秒
|
||||
# token固定超时 设为七天 (必定过期) 单位: 秒
|
||||
timeout: 604800
|
||||
# token活跃超时时间 30分钟(指定时间无操作则过期) 单位: 秒
|
||||
activity-timeout: 1800
|
||||
# 开启内网服务调用鉴权
|
||||
# 开启内网服务调用鉴权(不允许越过gateway访问内网服务 保障服务安全)
|
||||
check-same-token: true
|
||||
# Same-Token的有效期 (单位: 秒)(默认一天)
|
||||
# same-token-timeout: 600
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: false
|
||||
# 是否尝试从header里读取token
|
||||
is-read-header: true
|
||||
# 是否尝试从cookie里读取token
|
||||
is-read-cookie: false
|
||||
# token前缀
|
||||
token-prefix: "Bearer"
|
||||
# jwt秘钥
|
||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
||||
|
||||
|
|
@ -201,35 +170,12 @@ mybatis-plus:
|
|||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: org.dromara.**.domain
|
||||
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
||||
checkConfigLocation: false
|
||||
configuration:
|
||||
# 自动驼峰命名规则(camel case)映射
|
||||
mapUnderscoreToCamelCase: true
|
||||
# MyBatis 自动映射策略
|
||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||
autoMappingBehavior: FULL
|
||||
# MyBatis 自动映射时未知列或未知属性处理策
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: NONE
|
||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
# 是否打印 Logo banner
|
||||
banner: true
|
||||
dbConfig:
|
||||
# 主键类型
|
||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||
# 如需改为自增 需要将数据库表全部设置为自增
|
||||
idType: ASSIGN_ID
|
||||
# 逻辑已删除值
|
||||
logicDeleteValue: 2
|
||||
# 逻辑未删除值
|
||||
logicNotDeleteValue: 0
|
||||
insertStrategy: NOT_NULL
|
||||
updateStrategy: NOT_NULL
|
||||
where-strategy: NOT_NULL
|
||||
|
||||
# 数据加密
|
||||
mybatis-encryptor:
|
||||
|
|
@ -245,8 +191,14 @@ mybatis-encryptor:
|
|||
publicKey:
|
||||
privateKey:
|
||||
|
||||
# swagger配置
|
||||
swagger:
|
||||
# 接口文档配置
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
info:
|
||||
# 标题
|
||||
title: '标题:RuoYi-Cloud-Plus微服务权限管理系统_接口文档'
|
||||
|
|
@ -267,36 +219,14 @@ swagger:
|
|||
in: HEADER
|
||||
name: ${sa-token.token-name}
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
|
||||
# seata配置
|
||||
seata:
|
||||
# 默认关闭,如需启用spring.datasource.dynami.seata需要同时开启
|
||||
# 是否启用
|
||||
enabled: true
|
||||
# Seata 应用编号,默认为 ${spring.application.name}
|
||||
# Seata 应用编号,默认为应用名
|
||||
application-id: ${spring.application.name}
|
||||
# Seata 事务组编号,用于 TC 集群名
|
||||
tx-service-group: ${spring.application.name}-group
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: ${spring.cloud.nacos.server-addr}
|
||||
group: ${spring.cloud.nacos.config.group}
|
||||
namespace: ${spring.profiles.active}
|
||||
data-id: seata-server.properties
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
application: ruoyi-seata-server
|
||||
server-addr: ${spring.cloud.nacos.server-addr}
|
||||
group: ${spring.cloud.nacos.discovery.group}
|
||||
namespace: ${spring.profiles.active}
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ spring:
|
|||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: true
|
||||
# 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
|
||||
seata: true
|
||||
seata: ${seata.enabled}
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
hikari:
|
||||
|
|
@ -50,8 +50,3 @@ spring:
|
|||
connectionTestQuery: SELECT 1
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
# seata配置
|
||||
seata:
|
||||
# 关闭自动代理
|
||||
enable-auto-data-source-proxy: false
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ spring:
|
|||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: ruoyi
|
||||
author: LionLi
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: org.dromara.system
|
||||
# 自动去除表前缀,默认是false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package org.dromara.common.core.factory;
|
||||
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.support.DefaultPropertySourceFactory;
|
||||
import org.springframework.core.io.support.EncodedResource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* yml 配置源工厂
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class YmlPropertySourceFactory extends DefaultPropertySourceFactory {
|
||||
|
||||
@Override
|
||||
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
|
||||
String sourceName = resource.getResource().getFilename();
|
||||
if (StringUtils.isNotBlank(sourceName) && StringUtils.endsWithAny(sourceName, ".yml", ".yaml")) {
|
||||
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
|
||||
factory.setResources(resource.getResource());
|
||||
factory.afterPropertiesSet();
|
||||
return new PropertiesPropertySource(sourceName, factory.getObject());
|
||||
}
|
||||
return super.createPropertySource(name, resource);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "swagger")
|
||||
@ConfigurationProperties(prefix = "springdoc")
|
||||
public class SwaggerProperties {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package org.dromara.common.dubbo.config;
|
||||
|
||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
||||
import org.dromara.common.dubbo.properties.DubboCustomProperties;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* dubbo 配置类
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties(DubboCustomProperties.class)
|
||||
@PropertySource(value = "classpath:common-dubbo.yml", factory = YmlPropertySourceFactory.class)
|
||||
public class DubboConfiguration {
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package org.dromara.common.dubbo.properties;
|
||||
|
||||
import org.dromara.common.dubbo.enumd.RequestLogEnum;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.dubbo.enumd.RequestLogEnum;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
org.dromara.common.dubbo.properties.DubboCustomProperties
|
||||
org.dromara.common.dubbo.config.DubboConfiguration
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖
|
||||
dubbo:
|
||||
application:
|
||||
logger: slf4j
|
||||
# 元数据中心 local 本地 remote 远程 这里使用远程便于其他服务获取
|
||||
metadataType: remote
|
||||
# 可选值 interface、instance、all,默认是 all,即接口级地址、应用级地址都注册
|
||||
register-mode: instance
|
||||
service-discovery:
|
||||
# FORCE_INTERFACE,只消费接口级地址,如无地址则报错,单订阅 2.x 地址
|
||||
# APPLICATION_FIRST,智能决策接口级/应用级地址,双订阅
|
||||
# FORCE_APPLICATION,只消费应用级地址,如无地址则报错,单订阅 3.x 地址
|
||||
migration: FORCE_APPLICATION
|
||||
# 注册中心配置
|
||||
registry:
|
||||
address: nacos://${spring.cloud.nacos.server-addr}
|
||||
group: DUBBO_GROUP
|
||||
parameters:
|
||||
namespace: ${spring.profiles.active}
|
||||
# 消费者相关配置
|
||||
consumer:
|
||||
# 结果缓存(LRU算法)
|
||||
# 会有数据不一致问题 建议在注解局部开启
|
||||
cache: false
|
||||
# 支持校验注解
|
||||
validation: jvalidationNew
|
||||
# 调用重试 不包括第一次 0为不需要重试
|
||||
retries: 0
|
||||
# 初始化检查
|
||||
check: false
|
||||
|
|
@ -7,12 +7,14 @@ import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
|||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
||||
import org.dromara.common.mybatis.handler.CreateAndUpdateMetaObjectHandler;
|
||||
import org.dromara.common.mybatis.interceptor.PlusDataPermissionInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +25,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
@AutoConfiguration
|
||||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@MapperScan("${mybatis-plus.mapperPackage}")
|
||||
@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class)
|
||||
public class MybatisPlusConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
mybatis-plus:
|
||||
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
||||
checkConfigLocation: false
|
||||
configuration:
|
||||
# 自动驼峰命名规则(camel case)映射
|
||||
mapUnderscoreToCamelCase: true
|
||||
# MyBatis 自动映射策略
|
||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||
autoMappingBehavior: FULL
|
||||
# MyBatis 自动映射时未知列或未知属性处理策
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: NONE
|
||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
# 是否打印 Logo banner
|
||||
banner: true
|
||||
dbConfig:
|
||||
# 主键类型
|
||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||
idType: ASSIGN_ID
|
||||
# 逻辑已删除值(框架表均使用此值 禁止随意修改)
|
||||
logicDeleteValue: 2
|
||||
# 逻辑未删除值
|
||||
logicNotDeleteValue: 0
|
||||
insertStrategy: NOT_NULL
|
||||
updateStrategy: NOT_NULL
|
||||
whereStrategy: NOT_NULL
|
||||
|
|
@ -4,10 +4,12 @@ import cn.dev33.satoken.dao.SaTokenDao;
|
|||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
||||
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
|
||||
import org.dromara.common.satoken.core.service.SaPermissionImpl;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* Sa-Token 配置
|
||||
|
|
@ -15,6 +17,7 @@ import org.springframework.context.annotation.Bean;
|
|||
* @author Lion Li
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
|
||||
public class SaTokenConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖
|
||||
# Sa-Token配置
|
||||
sa-token:
|
||||
# 允许从 请求参数 读取 token
|
||||
is-read-body: true
|
||||
# 允许从 header 读取 token
|
||||
is-read-header: true
|
||||
# 关闭 cookie 鉴权 从根源杜绝 csrf 漏洞风险
|
||||
is-read-cookie: false
|
||||
# token前缀
|
||||
token-prefix: "Bearer"
|
||||
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo.extensions</groupId>
|
||||
<artifactId>dubbo-filter-seata</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package org.dromara.common.seata.config;
|
||||
|
||||
import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* seata 配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@PropertySource(value = "classpath:common-seata.yml", factory = YmlPropertySourceFactory.class)
|
||||
public class SeataConfiguration {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
org.dromara.common.seata.config.SeataConfiguration
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖
|
||||
# seata配置
|
||||
seata:
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: ${spring.cloud.nacos.server-addr}
|
||||
group: ${spring.cloud.nacos.config.group}
|
||||
namespace: ${spring.profiles.active}
|
||||
data-id: seata-server.properties
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
application: ruoyi-seata-server
|
||||
server-addr: ${spring.cloud.nacos.server-addr}
|
||||
group: ${spring.cloud.nacos.discovery.group}
|
||||
namespace: ${spring.profiles.active}
|
||||
# 关闭自动代理
|
||||
enable-auto-data-source-proxy: false
|
||||
Loading…
Reference in New Issue