Skip to content

Commit

Permalink
新增log脱敏
Browse files Browse the repository at this point in the history
  • Loading branch information
pcm committed Nov 8, 2024
1 parent e6b4f04 commit 3bdd789
Show file tree
Hide file tree
Showing 61 changed files with 3,528 additions and 0 deletions.
43 changes: 43 additions & 0 deletions springboot-log/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## springBoot-demo

springBoot-demo 是一个SpringBoot的基础框架项目,可以在此项目上进行扩展。

## 开发环境

- Java 8+
- Maven 3.5.4+
- SpringBoot 2.3.12.RELEASE
- mysql5.7+
- ant1.9+ (非必须,打包可用)


## 快速开始

**使用**

- git clone https://github.com/xuwujing/springBoot-study/springBoot-demo.git

**使用**

秉着开箱即用的原则,更改相应的配置(MySql、Es、Redis等地址配置),运行main方法,即可启动!

**注意**

EasyCode模板生成的xml若是没有逗号,则需要将全局模版velocityHasNext修改为foreach.hasNext。

## 项目结构

```
springBoot-demo
├── pom.xml
├── README.md
├── build-dev.bat ant打包脚本启动命令
├── build-dev.xml ant打包脚本
├── git-info.bat git信息获取
├── start.sh linux启动脚本
├── stop.sh linux停止动脚本
└── src
├── main
│   ├── java
│   │   └── com
│   │   └── pancm
1 change: 1 addition & 0 deletions springboot-log/build-dev.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ant -f build-dev.xml
55 changes: 55 additions & 0 deletions springboot-log/build-dev.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="springboot-demo" default="zip" basedir=".">
<property name="build" value="build" />
<property name="target" value="target" />
<property name="source" value="src/main/resources"/>
<property name="jar_version" value="springboot-demo_V1.0" />
<property name="routine" value="build/${jar_version}/程序包"/>

<record name="ant.log" loglevel="info" append="no" action="start"/>

<target name="clean">
<delete dir="${target}" />
<delete dir="${build}" />
<delete dir="${routine}" />
</target>

<target name="create-path" depends="clean">
<mkdir dir="${build}" />
<mkdir dir="${build}/${jar_version}" />
</target>


<target name="mvn_package" depends="create-path">
<exec executable="cmd.exe" >
<arg line="/c git-info.bat"/>
</exec>
<exec executable="cmd" failonerror="true">
<arg line="/c mvn clean package -P dev" />
</exec>
</target>





<target name="copyAll" depends="mvn_package">
<copy todir="${routine}" file="${target}/springboot-demo.jar"></copy>
<copy todir="${routine}" file="${source}/application.yml"></copy>
<copy todir="${routine}" file="${source}/application-dev.yml"></copy>
<copy todir="${routine}" file="${source}/version.txt"></copy>
<copy todir="${routine}" file="start.sh"></copy>
<copy todir="${routine}" file="stop.sh"></copy>
<rename src="${routine}/version.txt" dest="${routine}/springboot-demo-version.txt"/>
</target>

<!--文件打包-->
<target name="zip" depends="copyAll">
<zip destfile="build/${jar_version}.zip" basedir="${build}" excludes=".svn"/>
</target>

<target name="cleanFiles" depends="zip">
<delete dir="${build}/${jar_version}" />
</target>

</project>
42 changes: 42 additions & 0 deletions springboot-log/db/pcm.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Navicat Premium Data Transfer
Source Server : 本地-mysql
Source Server Type : MySQL
Source Server Version : 50744
Source Host : localhost:3306
Source Schema : pcm
Target Server Type : MySQL
Target Server Version : 50744
File Encoding : 65001
Date: 15/01/2024 15:40:52
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
`sex` tinyint(1) NULL DEFAULT 1 COMMENT '性别',
`age` int(4) NULL DEFAULT NULL COMMENT '年龄',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
`update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, '张三', 1, 18, '2020-02-15 14:35:46', 'admin', '2021-01-15 14:36:28', 'admin');
INSERT INTO `user` VALUES (2, '小红', 2, 26, '2022-02-16 14:36:10', 'admin', '2021-01-15 14:36:39', 'admin');

SET FOREIGN_KEY_CHECKS = 1;
155 changes: 155 additions & 0 deletions springboot-log/easycode/EasyCodeConfig.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions springboot-log/git-info.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
set time=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
set app=springboot-demo
for /F %%i in ('git rev-parse --short HEAD') do ( set commit_id=%%i)
for /F %%i in ('git rev-parse --abbrev-ref HEAD') do ( set branch_id=%%i)
echo build_app = %app% > ./src/main/resources/build.properties
echo build_time = %time% >> ./src/main/resources/build.properties
echo git_commit = %commit_id% >> ./src/main/resources/build.properties
echo git_branch = %branch_id% >> ./src/main/resources/build.properties
echo start %app% at %date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
::echo "build_version = '${version}'" > ./src/main/resources/build.properties
::echo "upload %app%"
::echo "done %app% %time% at $(date "+%Y-%m-%d %H:%M:%S")"
237 changes: 237 additions & 0 deletions springboot-log/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pancm</groupId>
<artifactId>springboot-log</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-log</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<jwt.version>3.5.0</jwt.version>
<cache.caffeine.version>2.6.2</cache.caffeine.version>
<swagger.version>2.9.2</swagger.version>
<swagger.model.version>1.5.21</swagger.model.version>
<swagger.bootstrap.ui.version>1.9.6</swagger.bootstrap.ui.version>
<alibaba.fastjson>1.2.62</alibaba.fastjson>
<mysql.connector.version>5.1.41</mysql.connector.version>
<alibaba.druid.version>1.1.12</alibaba.druid.version>
<pagehelper.version>4.0.3</pagehelper.version>
<mybatis.spring.boot.version>1.3.1</mybatis.spring.boot.version>
<tk.mybatis.boot.version>1.1.4</tk.mybatis.boot.version>
<swagger.version>2.9.2</swagger.version>
<swagger.model.version>1.5.21</swagger.model.version>
<swagger.bootstrap.ui.version>1.9.6</swagger.bootstrap.ui.version>
</properties>

<profiles>
<profile>
<!-- 本地开发环境 -->
<id>local</id>
<properties>
<spring.profiles.active>local</spring.profiles.active>
</properties>
<activation>
<!-- 设置默认激活这个配置 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<!-- 开发环境 -->
<id>dev</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
</profile>
<profile>
<!-- 生产环境 -->
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
</profile>
</profiles>


<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${alibaba.druid.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>${tk.mybatis.boot.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<!-- mybatis-generator-core 反向生成java代码,解决dtd 标红的问题-->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>


<!-- log -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>



<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${alibaba.fastjson}</version>
</dependency>

<!-- swagger api-doc -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- fix bug of Illegal DefaultValue for parameter type integer -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger.model.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- 这里使用 swagger-bootstrap-ui 替代了原有丑陋的ui~ -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger.bootstrap.ui.version}</version>
</dependency>

<!-- 脱敏日志 https://gitee.com/JustryDeng/logback-defender/tree/master -->
<dependency>
<groupId>com.idea-aedi</groupId>
<artifactId>logback-defender</artifactId>
<version>1.0.0</version>
</dependency>



</dependencies>

<build>
<finalName>springboot-log</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 3bdd789

Please sign in to comment.