libo 4 år sedan
förälder
incheckning
fb5748847f

+ 19 - 3
src/main/java/com/tdba/cxb/ares/api/controller/UserController.java

@@ -20,6 +20,9 @@ import java.time.ZonedDateTime;
20 20
 import java.util.List;
21 21
 import java.util.Map;
22 22
 import java.util.Objects;
23
+import java.util.concurrent.Callable;
24
+import java.util.concurrent.Exchanger;
25
+import java.util.concurrent.FutureTask;
23 26
 import java.util.function.Function;
24 27
 import java.util.stream.Collectors;
25 28
 
@@ -127,8 +130,21 @@ public class UserController {
127 130
                 Map.of("value", 4, "label", "代理商")));
128 131
     }
129 132
 
130
-    public static void main(String[] args) {
131
-        System.out.println(LocalDateTime.of(2022, 04, 18, 0, 0, 0).toEpochSecond(ZoneOffset.ofHours(8)));
132
-        System.out.println(LocalDateTime.of(2022, 04, 18, 23, 59, 59).toEpochSecond(ZoneOffset.ofHours(8)));
133
+    public static void main(String[] args) throws InterruptedException {
134
+
135
+        Exchanger exchanger = new Exchanger();
136
+
137
+        for (int i = 1; i <= 10; i++) {
138
+            Integer data = i;
139
+            new Thread(() -> {
140
+                try {
141
+                    Object exchange = exchanger.exchange(data);
142
+                    System.out.println(Thread.currentThread().getName() + "-" + exchange);
143
+                } catch (InterruptedException e) {
144
+                    e.printStackTrace();
145
+                }
146
+            }, "Java技术栈" + i).start();
147
+        }
148
+
133 149
     }
134 150
 }

+ 35 - 0
src/main/resources/logback-spring.xml

@@ -62,4 +62,39 @@
62 62
             <appender-ref ref="timeFileOutput"/>
63 63
         </root>
64 64
     </springProfile>
65
+
66
+    <springProfile name="pro">
67
+        <!--设置存储路径变量-->
68
+        <property name="USER_HOME" value="/data/www/wwwlogs" />
69
+
70
+        <!--文件输出,时间窗口滚动-->
71
+        <appender name="timeFileOutput" class="ch.qos.logback.core.rolling.RollingFileAppender">
72
+            <!--日志名,指定最新的文件名,其他文件名使用FileNamePattern -->
73
+            <File>${USER_HOME}/order-web/out.log</File>
74
+            <!--文件滚动模式-->
75
+            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
76
+                <!--日志文件输出的文件名,可设置文件类型为gz,开启文件压缩-->
77
+                <FileNamePattern>${USER_HOME}/order-web/info.%d{yyyy-MM-dd}.%i.log.gz</FileNamePattern>
78
+                <!--日志文件保留天数-->
79
+                <MaxHistory>30</MaxHistory>
80
+                <!--按大小分割同一天的-->
81
+                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
82
+                    <maxFileSize>10MB</maxFileSize>
83
+                </timeBasedFileNamingAndTriggeringPolicy>
84
+            </rollingPolicy>
85
+
86
+            <!--输出格式-->
87
+            <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
88
+                <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
89
+                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} %line - %msg%n</pattern>
90
+                <!--设置编码-->
91
+                <charset>UTF-8</charset>
92
+            </encoder>
93
+        </appender>
94
+
95
+        <root level="info">
96
+            <!--appender将会添加到这个loger-->
97
+            <appender-ref ref="timeFileOutput"/>
98
+        </root>
99
+    </springProfile>
65 100
 </configuration>