Bläddra i källkod

1、springboot配置管理

machaoyi 1 år sedan
förälder
incheckning
94a70cc401

+ 14 - 5
.idea/workspace.xml

@@ -5,10 +5,11 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="1dc46973-e6f5-473b-a131-bf2bbc2dca15" name="更改" comment="1、登录接口回传token,以便前端无法使用Cookie时使用">
-      <change afterPath="$PROJECT_DIR$/application/src/main/java/com/ctsi/Auth/entity/TokenInfoPO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/application/src/main/resources/application-dev.yml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/application/src/main/resources/application-prod.yml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/application/src/main/resources/application-test.yml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/application/src/main/java/com/ctsi/Auth/web/login.java" beforeDir="false" afterPath="$PROJECT_DIR$/application/src/main/java/com/ctsi/Auth/web/login.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/application/src/main/java/com/ctsi/config/SwaggerConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/application/src/main/java/com/ctsi/config/SwaggerConfig.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/application/src/main/resources/application.yml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -151,7 +152,7 @@
       <workItem from="1705392945258" duration="4784000" />
       <workItem from="1705397771531" duration="2808000" />
       <workItem from="1705452083011" duration="7637000" />
-      <workItem from="1705460446625" duration="18893000" />
+      <workItem from="1705460446625" duration="19446000" />
     </task>
     <task id="LOCAL-00001" summary="基础框架配置">
       <option name="closed" value="true" />
@@ -489,7 +490,15 @@
       <option name="project" value="LOCAL" />
       <updated>1705482687104</updated>
     </task>
-    <option name="localTasksCounter" value="43" />
+    <task id="LOCAL-00043" summary="1、登录接口回传token,以便前端无法使用Cookie时使用">
+      <option name="closed" value="true" />
+      <created>1705541613328</created>
+      <option name="number" value="00043" />
+      <option name="presentableId" value="LOCAL-00043" />
+      <option name="project" value="LOCAL" />
+      <updated>1705541613328</updated>
+    </task>
+    <option name="localTasksCounter" value="44" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">

+ 62 - 0
application/src/main/resources/application-dev.yml

@@ -0,0 +1,62 @@
+# 开发环境
+spring:
+  # 数据库配置
+  datasource:
+    url: jdbc:mysql://matrix34.tpddns.cn:13306/myframe?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
+    username: root
+    password: 9a41012499f38251
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  # redis
+  redis:
+    database: 1
+    # Redis服务器地址
+    host: 222.186.144.74
+    password: Geek@135#
+    # Redis服务器连接端口
+    port: 60101
+    # Redis服务器连接密码(默认为空)
+    # password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 200
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 10
+        # 连接池中的最小空闲连接
+        min-idle: 0
+# 服务器端口
+server:
+  port: 60006
+# 日志级别
+logging:
+  level:
+    root: info
+# swagger开关
+springfox:
+  documentation:
+    auto-startup: true #false关闭swagger文档 true打开swagger
+############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
+sa-token:
+  # token 名称(同时也是 cookie 名称)
+  token-name: token
+  # token 有效期(单位:秒) 默认30天,-1 代表永久有效
+  timeout: 86400
+  # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
+  active-timeout: -1
+  # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
+  is-concurrent: true
+  # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
+  is-share: true
+  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
+  token-style: uuid
+  # 是否输出操作日志
+  is-log: true
+# frame
+frame:
+  default-password: Root@0511
+  # 验证码配置
+  captcha-type: false

+ 62 - 0
application/src/main/resources/application-prod.yml

@@ -0,0 +1,62 @@
+# 生产环境
+spring:
+  # 数据库配置
+  datasource:
+    url: jdbc:mysql://matrix34.tpddns.cn:13306/myframe?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
+    username: root
+    password: 9a41012499f38251
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  # redis
+  redis:
+    database: 1
+    # Redis服务器地址
+    host: 222.186.144.74
+    password: Geek@135#
+    # Redis服务器连接端口
+    port: 60101
+    # Redis服务器连接密码(默认为空)
+    # password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 200
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 10
+        # 连接池中的最小空闲连接
+        min-idle: 0
+# 服务器端口
+server:
+  port: 60006
+# 日志级别
+logging:
+  level:
+    root: info
+# swagger开关
+springfox:
+  documentation:
+    auto-startup: false #false关闭swagger文档 true打开swagger
+############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
+sa-token:
+  # token 名称(同时也是 cookie 名称)
+  token-name: token
+  # token 有效期(单位:秒) 默认30天,-1 代表永久有效
+  timeout: 86400
+  # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
+  active-timeout: -1
+  # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
+  is-concurrent: true
+  # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
+  is-share: true
+  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
+  token-style: uuid
+  # 是否输出操作日志
+  is-log: true
+# frame
+frame:
+  default-password: Root@0511
+  # 验证码配置
+  captcha-type: true

+ 62 - 0
application/src/main/resources/application-test.yml

@@ -0,0 +1,62 @@
+# 测试环境
+spring:
+  # 数据库配置
+  datasource:
+    url: jdbc:mysql://matrix34.tpddns.cn:13306/myframe?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
+    username: root
+    password: 9a41012499f38251
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  # redis
+  redis:
+    database: 1
+    # Redis服务器地址
+    host: 222.186.144.74
+    password: Geek@135#
+    # Redis服务器连接端口
+    port: 60101
+    # Redis服务器连接密码(默认为空)
+    # password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 200
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 10
+        # 连接池中的最小空闲连接
+        min-idle: 0
+# 服务器端口
+server:
+  port: 60006
+# 日志级别
+logging:
+  level:
+    root: info
+# swagger开关
+springfox:
+  documentation:
+    auto-startup: true #false关闭swagger文档 true打开swagger
+############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
+sa-token:
+  # token 名称(同时也是 cookie 名称)
+  token-name: token
+  # token 有效期(单位:秒) 默认30天,-1 代表永久有效
+  timeout: 86400
+  # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
+  active-timeout: -1
+  # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
+  is-concurrent: true
+  # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
+  is-share: true
+  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
+  token-style: uuid
+  # 是否输出操作日志
+  is-log: true
+# frame
+frame:
+  default-password: Root@0511
+  # 验证码配置
+  captcha-type: true

+ 2 - 64
application/src/main/resources/application.yml

@@ -1,35 +1,8 @@
-# 应用程序名称
 spring:
   application:
     name: GeneralFrame
-  # 数据库配置
-  datasource:
-    url: jdbc:mysql://matrix34.tpddns.cn:13306/myframe?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
-    username: root
-    password: 9a41012499f38251
-    driver-class-name: com.mysql.cj.jdbc.Driver
-  # redis
-  redis:
-    database: 1
-    # Redis服务器地址
-    host: 222.186.144.74
-    password: Geek@135#
-    # Redis服务器连接端口
-    port: 60101
-    # Redis服务器连接密码(默认为空)
-    # password:
-    # 连接超时时间
-    timeout: 10s
-    lettuce:
-      pool:
-        # 连接池最大连接数
-        max-active: 200
-        # 连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: -1ms
-        # 连接池中的最大空闲连接
-        max-idle: 10
-        # 连接池中的最小空闲连接
-        min-idle: 0
+  profiles:
+    active: dev
 
 mybatis-plus:
   global-config:
@@ -39,38 +12,3 @@ mybatis-plus:
       logic-not-delete-value: 0
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-
-# 服务器端口
-server:
-  port: 60006
-
-# 日志级别
-logging:
-  level:
-    root: info
-# swagger开关
-springfox:
-  documentation:
-    auto-startup: true #false关闭swagger文档 true打开swagger
-############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
-sa-token:
-  # token 名称(同时也是 cookie 名称)
-  token-name: token
-  # token 有效期(单位:秒) 默认30天,-1 代表永久有效
-  timeout: 86400
-  # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
-  active-timeout: -1
-  # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
-  is-concurrent: true
-  # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
-  is-share: true
-  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
-  token-style: uuid
-  # 是否输出操作日志
-  is-log: true
-
-# frame
-frame:
-  default-password: Root@0511
-  # 验证码配置
-  captcha-type: true