整合配置中心为nacos,所有配置托管nacos

nacos
DongZeLiang 2024-04-01 09:09:59 +08:00
parent 22498a253d
commit 5a1ca931da
8 changed files with 143 additions and 91 deletions

3
doc/show 100644
View File

@ -0,0 +1,3 @@
https://github.com/alibaba/nacos/releases
在这个页面下载最新版的nacos
我的项目名称是muyu所以我创建了两个配置文件muyu-dev.yml和muyu-test.yml

View File

@ -0,0 +1,97 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
level:
com.ruoyi: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: dev
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
# MyBatis配置
mybatis:
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*

View File

@ -31,6 +31,7 @@
<velocity.version>2.3</velocity.version> <velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version> <jwt.version>0.9.1</jwt.version>
<knife4j.version>4.3.0</knife4j.version> <knife4j.version>4.3.0</knife4j.version>
<nacos.config.version>0.2.12</nacos.config.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -46,6 +47,13 @@
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<!-- nacos配置中心 -->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>${nacos.config.version}</version>
</dependency>
<!-- knife4j 依赖 --> <!-- knife4j 依赖 -->
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>

View File

@ -80,6 +80,12 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
</dependency> </dependency>
<!-- nacos配置中心 -->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,97 +1,34 @@
# 项目相关配置 # Tomcat
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.8.6
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server: server:
# 服务器的HTTP端口默认为8080 port: 9200
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置 # Spring
logging:
level:
com.ruoyi: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring: spring:
# 资源信息 application:
messages: # 应用名称
# 国际化资源文件路径 name: muyu
basename: i18n/messages
profiles: profiles:
# 环境配置
active: dev active: dev
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
nacos:
# token配置 config:
token: bootstrap:
# 令牌自定义标识 #开启系统启动时预读取nacos的配置用于满足@Value注入数据的场景
header: Authorization enable: true
# 令牌密钥 # 配置中心地址
secret: abcdefghijklmnopqrstuvwxyz server-addr: 127.0.0.1:8848
# 令牌有效期默认30分钟 # 配置文件ID
expireTime: 30 data-id: ${spring.application.name}-${spring.profiles.active}.${nacos.config.file-extension}
# 配置文件格式
# MyBatis配置 file-extension: yml
mybatis: # 开启自动刷新nacos配置
# 配置mapper的扫描找到所有的mapper.xml映射文件 auto-refresh: true
mapperLocations: classpath*:mapper/**/*Mapper.xml # 配置文件类型,对应nacos配置页面的配置格式默认是properties
# 加载全局的配置文件 type: yaml
configLocation: classpath:mybatis/mybatis-config.xml # 针对配置项同名的情况是否允许nacos的配置覆盖本地的配置
remote-first: true
# PageHelper分页插件 # 共享配置
pagehelper: ext-config:
helperDialect: mysql - data-id: application.${nacos.config.file-extension}
supportMethodsArguments: true type: yaml
params: count=countSql
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*

View File

@ -13,6 +13,7 @@ import com.ruoyi.generator.service.GenTableService;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;