Skip to content

Commit c2192a1

Browse files
author
Xiong Neng
committed
upgrade springboot-aop to spring boot 2
1 parent 69a6a73 commit c2192a1

File tree

7 files changed

+152
-27
lines changed

7 files changed

+152
-27
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ Spring Boot 现在已经成为Java 开发领域的一颗璀璨明珠,它本身
1111

1212
每个子项目都会使用最小依赖,大家拿来即可使用,自己可以根据业务需求自由组合搭配不同的技术构建项目。
1313

14+
加粗提醒:**主分支基于Spring Boot 2构建!**
15+
1416
## 项目简介
1517

1618
![](https://xnstatic-1253397658.file.myqcloud.com/SpringBootBucket.png)
1719

18-
1920
## 子项目列表
2021

2122
每个子项目会配有一篇博客文章的详细讲解 :point_right:
@@ -48,13 +49,16 @@ springboot-echarts | [集成Echarts导出图片](https://www.xncoding.c
4849

4950
## 环境
5051

51-
* maven latest
52-
* jdk 1.8
53-
* spring boot 1.5.10 release
54-
* intellij idea
52+
* JDK 1.8
53+
* Maven latest
54+
* Spring Boot 2.0.4
55+
* Intellij IDEA
5556
* mysql 5.7
57+
* mongodb
5658
* git 版本管理
5759
* nginx 反向代理
60+
* redis 缓存
61+
* rabbitmq 消息队列
5862

5963
## 运行
6064

@@ -77,9 +81,8 @@ springboot-echarts | [集成Echarts导出图片](https://www.xncoding.c
7781
## 后续计划
7882

7983
1. 集成OAuth2认证
80-
1. 集成QQ、微信、新浪微博第三方登录,配合shiro使用
84+
1. 集成GitHub、微信等第三方登录
8185
1. 集成网络爬虫框架
82-
1. 等SpringBoot 2稳定后全部升级至2
8386

8487
## 问题反馈
8588

springboot-aop/pom.xml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>1.5.10.RELEASE</version>
19-
<relativePath/>
18+
<version>2.0.4.RELEASE</version>
2019
</parent>
2120

2221
<properties>
@@ -53,7 +52,6 @@
5352
<artifactId>maven-compiler-plugin</artifactId>
5453
<version>3.6.1</version>
5554
<configuration>
56-
<!--<proc>none</proc>-->
5755
<source>1.8</source>
5856
<target>1.8</target>
5957
</configuration>
@@ -73,18 +71,6 @@
7371
</executions>
7472
</plugin>
7573
</plugins>
76-
77-
<resources>
78-
<resource>
79-
<directory>src/main/resources</directory>
80-
</resource>
81-
<resource>
82-
<directory>src/main/java</directory>
83-
<includes>
84-
<include>**/*.xml</include>
85-
</includes>
86-
</resource>
87-
</resources>
8874
</build>
8975

9076
</project>

springboot-aop/src/main/java/com/xncoding/aop/Application.java renamed to springboot-aop/src/main/java/com/xncoding/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.xncoding.aop;
1+
package com.xncoding;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xncoding.aop;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.CommandLineRunner;
6+
import org.springframework.core.annotation.Order;
7+
import org.springframework.stereotype.Component;
8+
9+
/**
10+
* MonitorBossAfterStart
11+
*
12+
* @author XiongNeng
13+
* @version 1.0
14+
* @since 2018/7/18
15+
*/
16+
@Component
17+
@Order(1)
18+
public class AfterStartRunner implements CommandLineRunner {
19+
20+
private Logger logger = LoggerFactory.getLogger(this.getClass());
21+
22+
public void run(String... args) {
23+
logger.debug("after start debug...");
24+
logger.info("after start info...");
25+
}
26+
}

springboot-aop/src/main/resources/application.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ spring:
2020

2121
logging:
2222
level:
23-
ROOT: INFO
24-
com:
25-
xncoding: DEBUG
26-
file: E:/logs/aop.log
23+
root: INFO
24+
com.xncoding: DEBUG
25+
path: D:/logs/springboot-aop
2726

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
_____ _______ _____ _____
3+
/\ \ /::\ \ /\ \ /\ \
4+
/::\____\ /::::\ \ /::\____\ /::\ \
5+
/:::/ / /::::::\ \ /:::/ / /::::\ \
6+
/:::/ / /::::::::\ \ /:::/ / /::::::\ \
7+
/:::/ / /:::/~~\:::\ \ /:::/ / /:::/\:::\ \
8+
/:::/ / /:::/ \:::\ \ /:::/____/ /:::/__\:::\ \
9+
/:::/ / /:::/ / \:::\ \ |::| | /::::\ \:::\ \
10+
/:::/ / /:::/____/ \:::\____\ |::| | _____ /::::::\ \:::\ \
11+
/:::/ / |:::| | |:::| | |::| | /\ \ /:::/\:::\ \:::\ \
12+
/:::/____/ |:::|____| |:::| | |::| | /::\____\/:::/__\:::\ \:::\____\
13+
\:::\ \ \:::\ \ /:::/ / |::| | /:::/ /\:::\ \:::\ \::/ /
14+
\:::\ \ \:::\ \ /:::/ / |::| | /:::/ / \:::\ \:::\ \/____/
15+
\:::\ \ \:::\ /:::/ / |::|____|/:::/ / \:::\ \:::\ \
16+
\:::\ \ \:::\__/:::/ / |:::::::::::/ / \:::\ \:::\____\
17+
\:::\ \ \::::::::/ / \::::::::::/____/ \:::\ \::/ /
18+
\:::\ \ \::::::/ / ~~~~~~~~~~ \:::\ \/____/
19+
\:::\ \ \::::/ / \:::\ \
20+
\:::\____\ \::/____/ \:::\____\
21+
\::/ / ~~ \::/ /
22+
\/____/ \/____/
23+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- scan 配置文件如果发生改变,将会被重新加载 scanPeriod 检测间隔时间-->
3+
<configuration scan="true" scanPeriod="60 seconds" debug="false">
4+
<contextName>springboot-aop</contextName>
5+
<include resource="org/springframework/boot/logging/logback/base.xml"/>
6+
<!-- 日志存储级别 -->
7+
<springProperty scope="context" name="rootlevel" source="logging.level.root" />
8+
<springProperty scope="context" name="busilevel" source="logging.level.com.xncoding" />
9+
<!-- 日志存储路径 -->
10+
<springProperty scope="context" name="logPath" source="logging.path" />
11+
<!-- 普通日志 -->
12+
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
13+
<file>${logPath}/springboot-aop.log</file>
14+
<!-- 循环政策:基于时间创建日志文件 -->
15+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
16+
<!-- 日志命名:单个文件大于128MB 按照时间+自增i 生成log文件 -->
17+
<fileNamePattern>${logPath}/springboot-aop-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
18+
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
19+
<maxFileSize>128MB</maxFileSize>
20+
</timeBasedFileNamingAndTriggeringPolicy>
21+
<!-- 最大保存时间:30天-->
22+
<maxHistory>30</maxHistory>
23+
</rollingPolicy>
24+
<append>true</append>
25+
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
26+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p ${PID:-} --- [%15thread] %logger:%-3L : %msg%n</pattern>
27+
<charset>utf-8</charset>
28+
</encoder>
29+
<filter class="ch.qos.logback.classic.filter.LevelFilter">
30+
<level>info</level>
31+
<onMatch>ACCEPT</onMatch>
32+
<onMismatch>DENY</onMismatch>
33+
</filter>
34+
</appender>
35+
<!-- 错误日志 -->
36+
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
37+
<file>${logPath}/springboot-aop-error.log</file>
38+
<!-- 循环政策:基于时间创建日志文件 -->
39+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
40+
<!-- 日志命名:单个文件大于2MB 按照时间+自增i 生成log文件 -->
41+
<fileNamePattern>${logPath}/springboot-aop-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
42+
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
43+
<maxFileSize>2MB</maxFileSize>
44+
</timeBasedFileNamingAndTriggeringPolicy>
45+
<!-- 最大保存时间:180天-->
46+
<maxHistory>180</maxHistory>
47+
</rollingPolicy>
48+
<append>true</append>
49+
<!-- 日志格式 -->
50+
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
51+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p ${PID:-} --- [%15thread] %logger:%-3L : %msg%n</pattern>
52+
<charset>utf-8</charset>
53+
</encoder>
54+
<!-- 日志级别过滤器 -->
55+
<filter class="ch.qos.logback.classic.filter.LevelFilter">
56+
<!-- 过滤的级别 -->
57+
<level>ERROR</level>
58+
<!-- 匹配时的操作:接收(记录) -->
59+
<onMatch>ACCEPT</onMatch>
60+
<!-- 不匹配时的操作:拒绝(不记录) -->
61+
<onMismatch>DENY</onMismatch>
62+
</filter>
63+
</appender>
64+
<!-- 控制台 -->
65+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
66+
<!-- 日志格式 -->
67+
<encoder>
68+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p ${PID:-} --- [%15thread] %logger:%-3L : %msg%n</pattern>
69+
<charset>utf-8</charset>
70+
</encoder>
71+
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
72+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
73+
<level>DEBUG</level>
74+
</filter>
75+
</appender>
76+
<!-- 屏蔽kafka的警告 -->
77+
<logger name="org.apache.kafka" level="ERROR"/>
78+
<!-- additivity 避免执行2次 -->
79+
<logger name="com.xncoding" level="${busilevel}" additivity="false">
80+
<appender-ref ref="STDOUT"/>
81+
<appender-ref ref="INFO_FILE"/>
82+
<appender-ref ref="ERROR_FILE"/>
83+
</logger>
84+
<root level="${rootlevel}">
85+
<appender-ref ref="INFO_FILE"/>
86+
<appender-ref ref="ERROR_FILE"/>
87+
</root>
88+
</configuration>

0 commit comments

Comments
 (0)