Freesia Spring配置文件与其他文件

common-api模块【application.yml文件】

project:
  version: @来自顶级pom.xml的properties配置@
---
spring:
  profiles:
	# 根据当前活跃环境指定对应的 application文件
	active: @profiles.active@
---
spring:
  datasource:
	driver-class-name: com.p6spy.engine.spy.P6SpyDriver
	url: jdbc:p6spy:mysql://localhost:3306/你的数据库?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&generateSimpleParameterMetadata=true&nullCatalogMeansCurrent=true
	username: 你的账号
	password: 你的密码
	type: com.alibaba.druid.pool.DruidDataSource
	druid:
	  # 初始连接数
	  initial-size: 5
	  # 最小连接池数量
	  min-idle: 5
	  # 最大连接池数量
	  max-active: 20
	  # 配置检测连接是否有效
	  validation-query: SELECT 1 FROM DUAL
	  test-while-idle: true
	  test-on-borrow: false
	  test-on-return: false
	  # 打开PSCache,并且指定每个连接上PSCache的大小
	  pool-prepared-statements: true
	  # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
	  max-pool-prepared-statement-per-connection-size: 20
	  filter:
		stat:
		  enabled: true
		  log-slow-sql: true
		  slow-sql-millis: 2000
		  merge-sql: true
		wall:
		  config:
			multi-statement-allow: true
	  use-global-data-source-stat: true
	  # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
	  connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
	  # 配置监控服务器
	  stat-view-servlet:
		enabled: true
		login-username: druid账号
		login-password: druid密码
		reset-enable: false
		url-pattern: /druid/*
		# 设置白名单,不填则允许所有访问
		allow: localhost
	  web-stat-filter:
		# 添加过滤规则
		url-pattern: /*
		# 忽略过滤格式
		exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
---
spring:
  data:
	redis:
	  repositories:
		enabled: false
---
spring:
  mvc:
	pathmatch:
	  matching-strategy: PATH_PATTERN_PARSER
---
spring:
  servlet:
	multipart:
	  # 单个文件大小
	  max-file-size: 10MB
	  # 所有文件上传总大小
	  max-request-size: 100MB
---
spring:
  redis:
	host: 127.0.0.1
	port: 6379
	lettuce:
	  pool:
		# 最大活动数量
		max-active: 8
		# 当池耗尽时,在引发异常之前,连接分配应该阻塞的最长时间。使用负值可以无限期阻止。
		max-wait: -1
		# 最大闲置时间,单位:s
		max-idle: 500
		# 超时关闭时间
	  shutdown-timeout: 0
---
spring:
  jpa:
	database: MYSQL
	database-platform: org.hibernate.dialect.MySQL8Dialect
	# 有p6spy了就可以不用你了
	show-sql: false
	open-in-view: true
	hibernate:
	  ddl-auto: update
	  generate_statistics: true
	  naming:
		physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
	properties:
	  hibernate:
		jdbc:
		  # 批量保存时重写SQL语句,每批1000条提交
		  batch_size: 1000
		  batch_versioned_data: true
		order_inserts: true
		order_updates: true
		# 定义JPA的SQL拦截,没有需要可以不创建
#        session_factory:
#          statement_inspector: com.freesia.interceptor.JpaDataPermissionInterceptor
# Mybatis
mybatis-plus:
  mapper-locations: classpath*:/mapper/*.xml
  configuration:
	log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
	lazy-loading-enabled: true
  # 启动时是否检查 MyBatis XML 文件的存在,默认不检查
  checkConfigLocation: false
  global-config:
	banner: false
	worker-id: ${random.int(1,31)}
	datacenter-id: ${random.int(1,31)}
	db-config:
	  id-type: ASSIGN_ID
# 日志相关
logging:
  config: classpath:logback-spring.xml
  level:
	root: INFO
# spring安全信息
management:
  endpoints:
	enabled-by-default: true
	web:
	  exposure:
		include: 'health'
  endpoint:
	health:
	  enabled: true
	  show-details: always

common-api模块 国际化i18n文件【messages_common.properties】

common-api -> resources -> 创建i18n文件夹并创建三个messages_common.properties文件

日志监控p6spy【spy.properteis】

# p6spy 性能分析插件配置文件
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
#appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
#日志输出到日志文件
# 使用日志系统记录 sql
appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
#deregisterdrivers=true
# 取消JDBC URL前缀
useprefix=true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,ok,resultset.
excludecategories=info,debug,result,commit,resultset
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# SQL语句打印时间格式
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2
# 是否过滤 Log
filter=true
# 过滤 Log 时所排除的 sql 关键字,以逗号分隔
exclude=SELECT 1

日志处理配置【logback-spring.xml】

<configuration debug="false" scan="true" scanPeriod="10 seconds">
	<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
	<contextName>logback</contextName>

	<!--输出sql语句-->
	<logger name="com.freesia" level="INFO"/>
	<property name="log.path" value="./logs/"/>
	<property name="maxHistory" value="7"/>
	<property name="maxFileSize" value="50MB"/>
	<property name="consolePattern"
			  value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) %yellow([%file : %line]%n) * %msg%n"/>
	<property name="logPattern" value="%date %level [%thread] %logger{36} [%file : %line] %msg%n"/>
	<springProperty name="springName" source="spring.application.name" defaultValue="freesia-default"/>

	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>INFO</level>
		</filter>
		<encoder>
			<pattern>${consolePattern}</pattern>
			<charset>utf-8</charset>
		</encoder>
	</appender>

	<appender name="info_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${log.path}/info.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!-- 每天一归档 -->
			<fileNamePattern>${log.path}/zip/logback_info.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern>
			<maxHistory>${maxHistory}</maxHistory>
			<timeBasedFileNamingAndTriggeringPolicy
					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>${maxFileSize}</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>
		<encoder>
			<pattern>${logPattern}</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>INFO</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<appender name="warn_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${log.path}/warn.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!-- 每天一归档 -->
			<fileNamePattern>${log.path}//zip/logback_warn.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern>
			<maxHistory>${maxHistory}</maxHistory>
			<timeBasedFileNamingAndTriggeringPolicy
					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>${maxFileSize}</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>
		<encoder>
			<pattern>${logPattern}</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>WARN</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>


	<appender name="error_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${log.path}/error.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!-- 每天一归档 -->
			<fileNamePattern>${log.path}//zip/logback_error.log.%d{yyyy-MM-dd}-%i.zip</fileNamePattern>
			<maxHistory>${maxHistory}</maxHistory>
			<timeBasedFileNamingAndTriggeringPolicy
					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>${maxFileSize}</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>
		<encoder>
			<pattern>${logPattern}</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<root>
		<level value="info"/>
		<appender-ref ref="console"/>
		<appender-ref ref="info_file"/>
		<appender-ref ref="warn_file"/>
		<appender-ref ref="error_file"/>
	</root>

</configuration>

web-app模块【application-dev.yml配置文件】

server:
  port: 8570
---
spring:
  application:
	name: freesia-admin
---
freesia:
  web:
	common:
	  # 是否初始化系统配置
	  init-sys-config: true
	  # 是否初始化数据字典
	  init-sys-dict: true
	tenant:
	  enabled: true
	  tenant-column: TENANT_ID
	  ignore-table: SYS_TENANT,SYS_USER,SYS_MENU,SYS_DEPT,SYS_ROLE,SYS_ROLE_MENU,SYS_ROLE_DEPT,SYS_TENANT_USER,SYS_USER_ROLE,SYS_DICT_KEY,SYS_DICT_VALUE,URL_CONFIG,SYS_CONFIG,SYS_OSS,SYS_OSS_CONFIG
---
login.password:
  # 密码最大错误次数
  maxRetryCount: 5
  # 密码锁定时间(默认10分钟 Duration)
  lockTime: 10M
---
# 生成验证码
captcha:
  type: CALCULATE
  strategy: CIRCLE
  numberLength: 1
  charLength: 4
---
spring:
  messages:
	# 引入不同模块的i18n messages文件,逗号分隔 
	basename: i18n/messages_common,i18n/messages
	encoding: UTF-8
---
# Sa-Token配置
sa-token:
  # 打印日志
  is-log: false
  # 打印彩色日志
  is-color-log: false
  # 启动不打印banner
  is-print: false
  # token名称 (同时也是cookie名称)
  token-name: Authorization
  # token有效期 设为一天 (必定过期) 单位: 秒
  timeout: 86400
  # 多端不同 token 有效期 可查看 USecurity.loginByDevice 方法自定义
  # token最低活跃时间 (指定时间无操作就过期) 单位: 秒
  active-timeout: 43200
  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
  is-concurrent: true
  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
  is-share: true
  # 是否尝试从header里读取token
  is-read-header: true
  # 是否尝试从cookie里读取token
  is-read-cookie: false
  # token前缀
  token-prefix: "Bearer"
  # jwt秘钥
  jwt-secret-key: DoYouLikeWhatYouSee?
---
# security配置
security:
  # 排除路径
  excludes:
	# 静态资源
	- /*.html
	- /**/*.html
	- /**/*.css
	- /**/*.js
	# 公共路径
	- /favicon.ico
	- /error
	# swagger 文档配置
	- /*/api-docs
	- /*/api-docs/**
	# actuator 监控配置
	- /actuator
	- /actuator/**
---
# 接口文档
springdoc:
  api-docs:
	enabled: true
  swagger-ui:
	path: /swagger-ui.html
	# 添加该属性才能在刷新或重新打开标签时不会重置auth值
	persist-authorization: true
  info:
	title: 接口文档的标题
	decription: 接口文档的描述
	license:
	  name: APACHE LICENSE VERSION 2.0
	  url: https://www.apache.org/licenses/LICENSE-2.0.html
	version: '版本号: ${project.version}'
	termsOfService: 'http://localhost:${server.port}}'
	contact:
	  name: Evad Devilvan
	  email: evaddevilvan@outlook.com
	  url: https://gitee.com/devilvan/freesia
  externalDocs:
	description: Git仓库地址
	url: https://gitee.com/devilvan/freesia
  components:
	# 鉴权方式配置
	security-schemes:
	  apiKey:
		type: APIKEY
		in: HEADER
		name: ${sa-token.token-name}
	  tenantId:
		type: APIKEY
		in: HEADER
		name: X-Tenent-Id
  group-configs:
	- group: 01. 登录、注册模块
	  paths-to-match:
		- /api/sysLoginController/**
		- /api/sysRegistryController/**
	- group: 02. 用户模块
	  paths-to-match: /api/sysUserController/**
	- group: 03. 角色模块
	  paths-to-match: /api/sysRoleController/**
	- group: 04. 菜单模块
	  paths-to-match: /api/sysMenuController/**
	- group: 05. 部门模块
	  paths-to-match: /api/sysDeptController/**
	- group: 06. 字典模块
	  paths-to-match: /api/sysDictController/**
	- group: 07. 操作日志模块
	  paths-to-match: /api/sysSensitiveLogController/**
	- group: 08. 数据面板模块
	  paths-to-match: /dashboard/**
	- group: 09. 基础服务模块
	  paths-to-match: /common/**
	- group: 10. 租户模块
	  paths-to-match: /api/sysTenantController/**
# knife4j的增强配置,不需要增强可以不配
#knife4j:
#  enable: true
#  setting:
#    language: zh_cn

web-api模块 国际化i18n文件【messages.properties】

web-api -> resources -> 创建i18n文件夹并创建三个messages.properties文件

Spring启动时的banner图案【banner.txt】

图案生成网址: http://www.network-science.de/ascii/

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

加把劲骑士RideOn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值