application.properties.example 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # ============================================
  2. # Snapshot 后端服务配置模板
  3. # ============================================
  4. # 使用说明:
  5. # 1. 复制此文件到 src/main/resources/application.properties
  6. # 2. 修改数据库密码等敏感信息
  7. # 3. 不要将包含真实密码的配置文件提交到Git
  8. # ============================================
  9. # 服务器配置
  10. server.port=7626
  11. server.servlet.context-path=/
  12. server.tomcat.uri-encoding=UTF-8
  13. server.tomcat.max-swallow-size=500MB
  14. # ============================================
  15. # 连接超时配置(解决上传卡顿问题)
  16. # ============================================
  17. # Tomcat连接超时(毫秒)- 30分钟,适应慢速网络
  18. server.tomcat.connection-timeout=1800000
  19. # Tomcat keep-alive超时(毫秒)- 30分钟
  20. server.tomcat.keep-alive-timeout=1800000
  21. # 最大线程数(增加并发处理能力)
  22. server.tomcat.max-threads=200
  23. server.tomcat.min-spare-threads=10
  24. # 最大连接数
  25. server.tomcat.max-connections=8192
  26. # 接受队列大小
  27. server.tomcat.accept-count=100
  28. # ============================================
  29. # 文件上传配置
  30. # ============================================
  31. spring.servlet.multipart.enabled=true
  32. spring.servlet.multipart.max-file-size=500MB
  33. spring.servlet.multipart.max-request-size=500MB
  34. spring.servlet.multipart.file-size-threshold=10MB
  35. # ============================================
  36. # 数据源配置
  37. # ============================================
  38. spring.datasource.url=jdbc:mysql://localhost:3306/snapshot?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
  39. spring.datasource.username=root
  40. # ⚠️ 请修改为你的MySQL密码
  41. spring.datasource.password=your_mysql_password_here
  42. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  43. # 激活开发环境配置(启用自动数据库初始化)
  44. spring.profiles.active=dev
  45. # ============================================
  46. # HikariCP 连接池配置
  47. # ============================================
  48. spring.datasource.hikari.connection-timeout=30000
  49. spring.datasource.hikari.maximum-pool-size=10
  50. spring.datasource.hikari.minimum-idle=5
  51. spring.datasource.hikari.idle-timeout=600000
  52. spring.datasource.hikari.max-lifetime=1800000
  53. spring.datasource.hikari.pool-name=SnapshotHikariCP
  54. # ============================================
  55. # MyBatis 配置
  56. # ============================================
  57. mybatis.mapper-locations=classpath:mapper/*.xml
  58. mybatis.type-aliases-package=com.snapshot.entity
  59. mybatis.configuration.map-underscore-to-camel-case=true
  60. mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
  61. # ============================================
  62. # JSON序列化配置
  63. # ============================================
  64. spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
  65. spring.jackson.time-zone=Asia/Shanghai
  66. spring.jackson.serialization.write-dates-as-timestamps=false
  67. spring.jackson.default-property-inclusion=non_null
  68. # ============================================
  69. # 日志配置
  70. # ============================================
  71. logging.level.root=INFO
  72. logging.level.com.snapshot=DEBUG
  73. logging.level.com.snapshot.mapper=DEBUG
  74. logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
  75. logging.file.name=logs/snapshot.log
  76. logging.file.max-size=10MB
  77. logging.file.max-history=30
  78. # ============================================
  79. # 应用自定义配置
  80. # ============================================
  81. # 文件存储路径
  82. app.file.upload-dir=./uploads
  83. app.file.max-size=524288000
  84. app.file.max-count=10
  85. # ID生成器配置
  86. app.id.length=8
  87. app.id.charset=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  88. # 过期清理任务配置
  89. app.cleanup.cron=0 0 */2 * * ?
  90. app.cleanup.enabled=true
  91. # ============================================
  92. # 一体化部署配置
  93. # ============================================
  94. # 服务访问地址配置(用于生成分享链接)
  95. # 格式:协议://域名:端口,如 http://snapshot.lemonai.online:7626
  96. # 如果不配置,则使用请求头中的Host和协议
  97. app.server.base-url=http://localhost:7626
  98. # ============================================
  99. # CORS配置(一体化部署后允许同源访问)
  100. # ============================================
  101. app.cors.allowed-origins=http://localhost:7626,http://127.0.0.1:7626
  102. app.cors.allowed-methods=GET,POST,PUT,DELETE,OPTIONS,PATCH
  103. app.cors.allowed-headers=*
  104. app.cors.allow-credentials=true
  105. app.cors.max-age=3600
  106. # ============================================
  107. # 静态资源配置
  108. # ============================================
  109. # 前端构建文件放置在 src/main/resources/static/ 目录
  110. # Spring Boot会自动提供静态资源服务
  111. app.static.resource.location=classpath:/static/