From df9ce8d356daceb0696855f3bad51676758c7e90 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 05 十月 2023 13:18:31 +0800
Subject: [PATCH] 添加初始化类、日志

---
 src/main/resources/mybatis.xml                               |   37 +++++++
 .gitignore                                                   |    1 
 src/main/resources/logback-spring.xml                        |  104 ++++++++++++++++++++
 src/main/java/com/smartearth/poiexcel/config/InitConfig.java |   26 +++++
 src/main/java/com/smartearth/poiexcel/entity/PlotEntity.java |   74 ++++++++++++++
 5 files changed, 242 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 549e00a..49de980 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@
 
 ### VS Code ###
 .vscode/
+log/
\ No newline at end of file
diff --git a/src/main/java/com/smartearth/poiexcel/config/InitConfig.java b/src/main/java/com/smartearth/poiexcel/config/InitConfig.java
new file mode 100644
index 0000000..6917ff4
--- /dev/null
+++ b/src/main/java/com/smartearth/poiexcel/config/InitConfig.java
@@ -0,0 +1,26 @@
+package com.smartearth.poiexcel.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+/**
+ * 鍒濆鍖栧畬鎴愰厤缃被
+ * @author WWW
+ */
+@Component
+public class InitConfig implements ApplicationRunner {
+    private final static Log log = LogFactory.getLog(InitConfig.class);
+
+    @Override
+    public void run(ApplicationArguments args) {
+        // noinspection AlibabaRemoveCommentedCode
+        try {
+            log.info("***************** 绯荤粺鍚姩瀹屾瘯 *****************" + "\n");
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+    }
+}
diff --git a/src/main/java/com/smartearth/poiexcel/entity/PlotEntity.java b/src/main/java/com/smartearth/poiexcel/entity/PlotEntity.java
new file mode 100644
index 0000000..a377d3f
--- /dev/null
+++ b/src/main/java/com/smartearth/poiexcel/entity/PlotEntity.java
@@ -0,0 +1,74 @@
+package com.smartearth.poiexcel.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 鍦板潡瀹炰綋绫�
+ * @author WWW
+ * @date 2023-10-05
+ */
+@Data
+@AllArgsConstructor
+@TableName("smart_earth.yz_dikuaixinxi")
+@EqualsAndHashCode(callSuper = false)
+public class PlotEntity implements Serializable {
+    private static final long serialVersionUID = -8624235184539814991L;
+
+    private Long id;
+
+    private String name;
+
+    private Double x;
+
+    private Double y;
+
+    private String point_area;
+
+    public PlotEntity() {
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getX() {
+        return x;
+    }
+
+    public void setX(Double x) {
+        this.x = x;
+    }
+
+    public Double getY() {
+        return y;
+    }
+
+    public void setY(Double y) {
+        this.y = y;
+    }
+
+    public String getPoint_area() {
+        return point_area;
+    }
+
+    public void setPoint_area(String point_area) {
+        this.point_area = point_area;
+    }
+}
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..0cbd6fd
--- /dev/null
+++ b/src/main/resources/logback-spring.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- scan 閰嶇疆鏂囦欢濡傛灉鍙戠敓鏀瑰彉锛屽皢浼氳閲嶆柊鍔犺浇  scanPeriod 妫�娴嬮棿闅旀椂闂�-->
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <contextName>PoieExcel</contextName>
+
+    <!-- 鏂囦欢鍚嶇О -->
+    <property name="log.name.info" value="info" />
+    <property name="log.name.error" value="error" />
+
+    <!-- info 鍦板潃 -->
+    <property name="log.path.info" value="logs/" />
+    <property name="log.file.info" value="logs/info.log" />
+
+    <!-- error,閿欒璺緞 -->
+    <property name="log.path.error" value="logs/" />
+    <property name="log.file.error" value="logs/error.log" />
+    <include resource="org/springframework/boot/logging/logback/base.xml"/>
+
+    <!-- 鏅�氭棩蹇� -->
+    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.file.info}</file>
+        <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 鏃ュ織鍛藉悕:鍗曚釜鏂囦欢澶т簬256MB 鎸夌収鏃堕棿+鑷i 鐢熸垚log鏂囦欢 -->
+            <fileNamePattern>${log.path.info}${log.name.info}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>256MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!-- 鏈�澶т繚瀛樻椂闂达細30澶�-->
+            <maxHistory>30</maxHistory>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <!-- 鏃ュ織绾у埆杩囨护鍣� -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 杩囨护鐨勭骇鍒� -->
+            <level>INFO</level>
+            <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� -->
+            <onMatch>ACCEPT</onMatch>
+            <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 閿欒鏃ュ織 -->
+    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.file.error}</file>
+        <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 鏃ュ織鍛藉悕:鍗曚釜鏂囦欢澶т簬128MB 鎸夌収鏃堕棿+鑷i 鐢熸垚log鏂囦欢 -->
+            <fileNamePattern>${log.path.error}${log.name.error}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>128MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!-- 鏈�澶т繚瀛樻椂闂达細180澶�-->
+            <maxHistory>180</maxHistory>
+        </rollingPolicy>
+        <append>true</append>
+        <!-- 鏃ュ織鏍煎紡 -->
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <!-- 鏃ュ織绾у埆杩囨护鍣� -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 杩囨护鐨勭骇鍒� -->
+            <level>ERROR</level>
+            <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� -->
+            <onMatch>ACCEPT</onMatch>
+            <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 鎺у埗鍙� -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <!-- 鏃ュ織鏍煎紡 -->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <!--姝ゆ棩蹇梐ppender鏄负寮�鍙戜娇鐢紝鍙厤缃渶搴曠骇鍒紝鎺у埗鍙拌緭鍑虹殑鏃ュ織绾у埆鏄ぇ浜庢垨绛変簬姝ょ骇鍒殑鏃ュ織淇℃伅-->
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <!-- 鍙湁杩欎釜鏃ュ織鏉冮檺鎵嶈兘鐪嬶紝sql璇彞 -->
+            <level>DEBUG</level>
+        </filter>
+    </appender>
+
+    <!-- 杈撳嚭sql鏃ュ織:ERROR,INFO,DEBUG -->
+    <logger name="com.apache.ibatis" level="INFO"/>
+
+    <!-- additivity:鏄惁鍦ㄧ埗(杩欓噷涓簉oot鑺傜偣)杈撳嚭, 榛樿 true; -->
+    <logger name="com.smartearth.poiexcel" level="INFO" additivity="true">
+        <appender-ref ref="INFO_FILE"/>
+        <appender-ref ref="ERROR_FILE"/>
+    </logger>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git a/src/main/resources/mybatis.xml b/src/main/resources/mybatis.xml
new file mode 100644
index 0000000..754cee0
--- /dev/null
+++ b/src/main/resources/mybatis.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <!--閰嶇疆褰卞搷鎵�鏈夋槧灏勫櫒涓厤缃紦瀛�-->
+        <setting name="cacheEnabled" value="true"/>
+        <!--寤惰繜鍔犺浇-->
+        <setting name="lazyLoadingEnabled" value="true"/>
+        <!--鏄惁鍏佽鍗曚竴璇彞杩斿洖澶氱粨鏋滈泦-->
+        <setting name="multipleResultSetsEnabled" value="true"/>
+        <!--浣跨敤鍒楁爣绛句唬鏇垮垪鍚�-->
+        <setting name="useColumnLabel" value="true"/>
+        <!--鍏佽JDBC 鏀寔鑷姩鐢熸垚涓婚敭-->
+        <setting name="useGeneratedKeys" value="false"/>
+        <!--璁剧疆SQL瓒呮椂鏃堕棿锛岀-->
+        <setting name="defaultStatementTimeout" value="360"/>
+        <!--榛樿杩斿洖鐨勬潯鏁伴檺鍒�-->
+        <setting name="defaultFetchSize" value="1000"/>
+        <!--鏄惁寮�鍚嚜鍔ㄩ┘宄板懡鍚嶈鍒欐槧灏勶紝鍗充粠缁忓吀鏁版嵁搴撳垪鍚� A_COLUMN 鍒扮粡鍏� Java 灞炴�у悕 aColumn 鐨勭被浼兼槧灏�-->
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+        <!--MyBatis 鍒╃敤鏈湴缂撳瓨鏈哄埗锛圠ocal Cache锛夐槻姝㈠惊鐜紩鐢紙circular references锛夊拰鍔犻�熻仈澶嶅祵濂楁熁璇€��-->
+        <setting name="localCacheScope" value="SESSION"/>
+        <!--褰撴病鏈変负鍙傛暟鎻愪緵鐗瑰畾鐨� JDBC 绫诲瀷鏃讹紝涓虹┖鍊兼寚瀹� JDBC 绫诲瀷-->
+        <setting name="jdbcTypeForNull" value="NULL"/>
+        <!--鎸囧畾鍝釜瀵硅薄鐨勬柟娉曡Е鍙戜竴娆″欢杩熷姞杞�-->
+        <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/>
+        <!--鎸囧畾褰撶粨鏋滈泦涓�间负 null 鏃讹紝鏄惁璋冪敤鏄犲皠瀵硅薄鐨� setter锛坢ap 瀵硅薄鏃朵负 put锛夋柟娉�-->
+        <setting name="callSettersOnNulls" value="true"/>
+        <!--鎸囧畾 MyBatis 鎵�鐢ㄦ棩蹇楃殑鍏蜂綋瀹炵幇锛歀OG4J/LOG4J2/SLF4J/STDOUT_LOGGING/NO_LOGGING-->
+        <setting name="logImpl" value="NO_LOGGING" />
+    </settings>
+    <typeAliases>
+        <package name="com.smartearth.poiexcel.entity"/>
+    </typeAliases>
+</configuration>
\ No newline at end of file

--
Gitblit v1.9.3