浏览代码

读写配置文件区分

JiahengHe 1 年之前
父节点
当前提交
ce853f6192

+ 1 - 1
price_collection/src/main/java/com/liangjiang/price_collection/service/impl/TableServiceImpl.java

@@ -126,7 +126,7 @@ public class TableServiceImpl implements ITableService {
     }
 
     // 3-10: 最少有3个并发消费者,最多可以扩展到10个并发消费者。消息处理的顺序性无法保证(此处业务不涉及强顺序)
-    @JmsListener(destination = "priceQueue", concurrency = "3-10")
+    @JmsListener(destination = "priceQueue", concurrency = "5-10")
     public void receivePriceInfo(ObjectMessage objectMessage){
 //        long start = System.currentTimeMillis();
         try {

+ 6 - 4
price_collection/src/main/resources/application.yml

@@ -1,4 +1,6 @@
 server:
+  servlet:
+    context-path: /priceCollect
   port: 82
   tomcat:
     uri-encoding: UTF-8
@@ -15,8 +17,8 @@ spring:
     time-zone: GMT+8
   datasource:
     username: root
-    password: zxc123...
-    url: jdbc:mysql://as.skyfffire.com:3306/one_price_warehouse?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
+    password: qwe123...
+    url: jdbc:mysql://kline.skyfffire.com:3306/one_price_warehouse?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
@@ -37,10 +39,10 @@ spring:
             none-base-statement-allow: true
             multi-statement-allow: true
       # 配置监控统计拦截的filters,去掉后监控界面sql无法统计。‘wall’用于防火墙
-#      filters: stat,wall
+  #      filters: stat,wall
 
   activemq:
-    broker-url: tcp://127.0.0.1:61616
+    broker-url: tcp://kline.skyfffire.com:61616
     packages:
       # 配置信任所有包 为了支持发送对象消息
       trust-all: true

+ 83 - 0
price_collection/src/main/resources/basic_application.yml.simple

@@ -0,0 +1,83 @@
+server:
+  servlet:
+    context-path: /priceCollect
+  port: 82
+  tomcat:
+    uri-encoding: UTF-8
+logging:
+  config: classpath:log.xml
+spring:
+  application:
+    name: price_collection
+  main:
+    allow-bean-definition-overriding: true
+    allow-circular-references: true
+  # 全局配置响应日期格式和时区为东八区,解决日期类型返回前端少八个小时的问题
+  jackson:
+    time-zone: GMT+8
+  datasource:
+    username: root
+    password: qwe123...
+    url: jdbc:mysql://kline.skyfffire.com:3306/one_price_warehouse?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.alibaba.druid.pool.DruidDataSource
+    druid:
+      initial-size: 20
+      max-active: 80
+      min-idle: 20
+      max-wait: 60000
+      timeBetweenEvictionRunsMillis: 60000
+      minEvictableIdleTimeMillis: 1800000
+      validationQuery: SELECT 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      poolPreparedStatements: true
+      filter:
+        wall:
+          config:
+            none-base-statement-allow: true
+            multi-statement-allow: true
+      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计。‘wall’用于防火墙
+#      filters: stat,wall
+
+  activemq:
+    broker-url: tcp://kline.skyfffire.com:61616
+    packages:
+      # 配置信任所有包 为了支持发送对象消息
+      trust-all: true
+    user: admin
+    password: admin
+
+#  redis:
+#    # Redis服务器地址
+#    host: localhost
+#    # Redis数据库索引(默认为0)
+#    database: 0
+#    # Redis服务器连接端口
+#    port: 6379
+#    # Redis服务器连接密码(默认为空)
+#    password: 123456
+#    # 连接超时时间
+#    timeout: 1000ms
+#    lettuce:
+#      pool:
+#        # 连接池最大连接数
+#        max-active: 8
+#        # 连接池最大空闲连接数
+#        max-idle: 8
+#        # 连接池最小空闲连接数
+#        min-idle: 0
+#        # 连接池最大阻塞等待时间,负值表示没有限制
+#        max-wait: -1ms
+mybatis-plus:
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  type-aliases-package: com.liangjiang.price_collection.domain
+  global-config:
+    banner: false
+    db-config:
+      id-type: input
+  configuration:
+    # 控制台SQL日志
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: false

+ 51 - 0
price_collection/src/main/resources/log_write.xml

@@ -0,0 +1,51 @@
+<configuration>
+    <!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,, -->
+    <!-- appender是configuration的子节点,是负责写日志的组件。 -->
+    <!-- ConsoleAppender:把日志输出到控制台 -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d %p (%file:%line\)- %m%n</pattern>
+            <!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 -->
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+    <!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 -->
+    <!-- 以下的大概意思是:1.先按日期存日志,日期变了,将前一天的日志文件名重命名为XXX%日期%索引,新的日志仍然是sys.log -->
+    <!--             2.如果日期没有发生变化,但是当前日志的文件大小超过1KB时,对当前日志进行分割 重命名-->
+    <appender name="syslog"
+              class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>logs/basics_write/sys.log</File>
+        <!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
+        <!-- TimeBasedRollingPolicy: 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 活动文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
+            <!-- 文件名:log/sys.2022-3-09.0.log -->
+            <fileNamePattern>logs/basics_write/sys.%d.%i.log</fileNamePattern>
+            <!-- 每产生一个日志文件,该日志文件的保存期限为30天 -->
+            <maxHistory>30</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy  class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <!-- maxFileSize:这是活动文件的大小,默认值是10MB -->
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder>
+            <!-- pattern节点,用来设置日志的输入格式 -->
+            <pattern>
+                %d %p (%file:%line\)- %m%n
+            </pattern>
+            <!-- 记录日志的编码 -->
+            <charset>UTF-8</charset> <!-- 此处设置字符集 -->
+        </encoder>
+    </appender>
+
+    <!-- 控制台输出日志级别 -->
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+    <!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
+    <!-- com.lightyears为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
+    <!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE  -->
+    <logger name="com.liangjiang.basics" level="DEBUG">
+        <appender-ref ref="syslog" />
+    </logger>
+</configuration>

+ 83 - 0
price_collection/src/main/resources/write_application.yml.simple

@@ -0,0 +1,83 @@
+server:
+  servlet:
+    context-path: /priceCollect1
+  port: 83
+  tomcat:
+    uri-encoding: UTF-8
+logging:
+  config: classpath:log.xml
+spring:
+  application:
+    name: write_price_collection
+  main:
+    allow-bean-definition-overriding: true
+    allow-circular-references: true
+  # 全局配置响应日期格式和时区为东八区,解决日期类型返回前端少八个小时的问题
+  jackson:
+    time-zone: GMT+8
+  datasource:
+    username: root
+    password: qwe123...
+    url: jdbc:mysql://kline.skyfffire.com:3306/one_price_warehouse?characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.alibaba.druid.pool.DruidDataSource
+    druid:
+      initial-size: 20
+      max-active: 80
+      min-idle: 20
+      max-wait: 60000
+      timeBetweenEvictionRunsMillis: 60000
+      minEvictableIdleTimeMillis: 1800000
+      validationQuery: SELECT 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      poolPreparedStatements: true
+      filter:
+        wall:
+          config:
+            none-base-statement-allow: true
+            multi-statement-allow: true
+      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计。‘wall’用于防火墙
+#      filters: stat,wall
+
+  activemq:
+    broker-url: tcp://kline.skyfffire.com:61616
+    packages:
+      # 配置信任所有包 为了支持发送对象消息
+      trust-all: true
+    user: admin
+    password: admin
+
+#  redis:
+#    # Redis服务器地址
+#    host: localhost
+#    # Redis数据库索引(默认为0)
+#    database: 0
+#    # Redis服务器连接端口
+#    port: 6379
+#    # Redis服务器连接密码(默认为空)
+#    password: 123456
+#    # 连接超时时间
+#    timeout: 1000ms
+#    lettuce:
+#      pool:
+#        # 连接池最大连接数
+#        max-active: 8
+#        # 连接池最大空闲连接数
+#        max-idle: 8
+#        # 连接池最小空闲连接数
+#        min-idle: 0
+#        # 连接池最大阻塞等待时间,负值表示没有限制
+#        max-wait: -1ms
+mybatis-plus:
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  type-aliases-package: com.liangjiang.price_collection.domain
+  global-config:
+    banner: false
+    db-config:
+      id-type: input
+  configuration:
+    # 控制台SQL日志
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: false