From bc2766b18bce90804ce04e4b184ea855f5d0146c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Fri, 8 Oct 2021 16:43:42 +0800 Subject: [PATCH 01/14] =?UTF-8?q?Spring=20Boot=202.x=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=95=99=E7=A8=8B=EF=BC=9A=E4=BD=BF=E7=94=A8PostgreSQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 1 + 2.x/README_zh.md | 2 +- 2.x/chapter6-4/pom.xml | 65 +++++++++++++++++++ .../chapter64/Chapter64Application.java | 14 ++++ .../com/didispace/chapter64/UserInfo.java | 26 ++++++++ .../chapter64/UserInfoRepository.java | 22 +++++++ .../src/main/resources/application.properties | 7 ++ .../didispace/chapter64/ApplicationTests.java | 51 +++++++++++++++ 2.x/pom.xml | 5 +- 9 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 2.x/chapter6-4/pom.xml create mode 100644 2.x/chapter6-4/src/main/java/com/didispace/chapter64/Chapter64Application.java create mode 100644 2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfo.java create mode 100644 2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfoRepository.java create mode 100644 2.x/chapter6-4/src/main/resources/application.properties create mode 100644 2.x/chapter6-4/src/test/java/com/didispace/chapter64/ApplicationTests.java diff --git a/2.x/README.md b/2.x/README.md index a6627efd..ab41abb3 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -72,6 +72,7 @@ - [Spring Boot 2.x基础教程:使用MongoDB](http://blog.didispace.com/spring-boot-learning-24-6-1/) - [Spring Boot 2.x基础教程:使用LDAP来管理用户与组织数据](http://blog.didispace.com/spring-boot-learning-24-6-2/) - [Spring Boot 2.x基础教程:使用时序数据库InfluxDB](http://blog.didispace.com/spring-boot-learning-2-6-3/) +- [Spring Boot 2.x基础教程:使用PostgreSQL](http://blog.didispace.com/spring-boot-learning-2-6-4/) ### Web开发 diff --git a/2.x/README_zh.md b/2.x/README_zh.md index fd94ee25..0f3471d0 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -73,7 +73,7 @@ - [Spring Boot 2.x基础教程:使用MongoDB](http://blog.didispace.com/spring-boot-learning-24-6-1/) - [Spring Boot 2.x基础教程:使用LDAP来管理用户与组织数据](http://blog.didispace.com/spring-boot-learning-24-6-2/) - [Spring Boot 2.x基础教程:使用时序数据库InfluxDB](http://blog.didispace.com/spring-boot-learning-2-6-3/) - +- [Spring Boot 2.x基础教程:使用PostgreSQL](http://blog.didispace.com/spring-boot-learning-2-6-4/) ### Web开发 diff --git a/2.x/chapter6-4/pom.xml b/2.x/chapter6-4/pom.xml new file mode 100644 index 00000000..c1683b06 --- /dev/null +++ b/2.x/chapter6-4/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + com.didispace + chapter6-4 + 1.0.0 + jar + 使用PostgreSQL数据库 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.1 + + + + + UTF-8 + 1.8 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.postgresql + postgresql + runtime + + + + org.projectlombok + lombok + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/2.x/chapter6-4/src/main/java/com/didispace/chapter64/Chapter64Application.java b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/Chapter64Application.java new file mode 100644 index 00000000..83ebf477 --- /dev/null +++ b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/Chapter64Application.java @@ -0,0 +1,14 @@ +package com.didispace.chapter64; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +public class Chapter64Application { + + public static void main(String[] args) { + SpringApplication.run(Chapter64Application.class, args); + } + +} diff --git a/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfo.java b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfo.java new file mode 100644 index 00000000..cc83d361 --- /dev/null +++ b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfo.java @@ -0,0 +1,26 @@ +package com.didispace.chapter64; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +@Data +@NoArgsConstructor +public class UserInfo { + + @Id + @GeneratedValue + private Long id; + + private String name; + private Integer age; + + public UserInfo(String name, Integer age) { + this.name = name; + this.age = age; + } +} \ No newline at end of file diff --git a/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfoRepository.java b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfoRepository.java new file mode 100644 index 00000000..85214e24 --- /dev/null +++ b/2.x/chapter6-4/src/main/java/com/didispace/chapter64/UserInfoRepository.java @@ -0,0 +1,22 @@ +package com.didispace.chapter64; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +/** + * Created by 程序猿DD/翟永超 on 2021/10/08. + *

+ * Blog: http://blog.didispace.com/ + * Github: https://github.com/dyc87112/ + */ +public interface UserInfoRepository extends JpaRepository { + + UserInfo findByName(String name); + + UserInfo findByNameAndAge(String name, Integer age); + + @Query("from UserInfo u where u.name=:name") + UserInfo findUser(@Param("name") String name); + +} diff --git a/2.x/chapter6-4/src/main/resources/application.properties b/2.x/chapter6-4/src/main/resources/application.properties new file mode 100644 index 00000000..3c000bf2 --- /dev/null +++ b/2.x/chapter6-4/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/test +spring.datasource.username=postgres +spring.datasource.password=123456 +spring.datasource.driver-class-name=org.postgresql.Driver + +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.properties.hibernate.hbm2ddl.auto=create \ No newline at end of file diff --git a/2.x/chapter6-4/src/test/java/com/didispace/chapter64/ApplicationTests.java b/2.x/chapter6-4/src/test/java/com/didispace/chapter64/ApplicationTests.java new file mode 100644 index 00000000..1ae64fb4 --- /dev/null +++ b/2.x/chapter6-4/src/test/java/com/didispace/chapter64/ApplicationTests.java @@ -0,0 +1,51 @@ +package com.didispace.chapter64; + + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@Slf4j +@SpringBootTest +public class ApplicationTests { + + @Autowired + private UserInfoRepository userRepository; + + @Test + public void test() throws Exception { + // 创建10条记录 + userRepository.save(new UserInfo("AAA", 10)); + userRepository.save(new UserInfo("BBB", 20)); + userRepository.save(new UserInfo("CCC", 30)); + userRepository.save(new UserInfo("DDD", 40)); + userRepository.save(new UserInfo("EEE", 50)); + userRepository.save(new UserInfo("FFF", 60)); + userRepository.save(new UserInfo("GGG", 70)); + userRepository.save(new UserInfo("HHH", 80)); + userRepository.save(new UserInfo("III", 90)); + userRepository.save(new UserInfo("JJJ", 100)); + + // 测试findAll, 查询所有记录 + Assertions.assertEquals(10, userRepository.findAll().size()); + + // 测试findByName, 查询姓名为FFF的User + Assertions.assertEquals(60, userRepository.findByName("FFF").getAge().longValue()); + + // 测试findUser, 查询姓名为FFF的User + Assertions.assertEquals(60, userRepository.findUser("FFF").getAge().longValue()); + + // 测试findByNameAndAge, 查询姓名为FFF并且年龄为60的User + Assertions.assertEquals("FFF", userRepository.findByNameAndAge("FFF", 60).getName()); + + // 测试删除姓名为AAA的User + userRepository.delete(userRepository.findByName("AAA")); + + // 测试findAll, 查询所有记录, 验证上面的删除是否成功 + Assertions.assertEquals(9, userRepository.findAll().size()); + + } + +} diff --git a/2.x/pom.xml b/2.x/pom.xml index 293aad51..4c21f4b1 100644 --- a/2.x/pom.xml +++ b/2.x/pom.xml @@ -64,11 +64,12 @@ chapter5-5 - + chapter6-1 chapter6-2 chapter6-3 - + chapter6-4 + chapter7-1 From 68f2ab0dc83e5cf23146f8e387a482347c6503fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Tue, 12 Oct 2021 13:38:03 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 13 ++++++++++--- 2.x/README_zh.md | 12 ++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/2.x/README.md b/2.x/README.md index ab41abb3..94e15452 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -84,14 +84,17 @@ ### 任务管理 -**定时任务** +**定时任务:`@Scheduled`实现** - [Spring Boot 2.x基础教程:使用@Scheduled实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-1) + +**定时任务:Elastic Job实现** + - [Spring Boot 2.x基础教程:使用Elastic Job实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-2) - [Spring Boot 2.x基础教程:使用Elastic Job的分片配置提高执行效率](https://blog.didispace.com/spring-boot-learning-2-7-3) - [Spring Boot 2.x基础教程:使用Elastic Job的namespace防止任务名冲突](https://blog.didispace.com/spring-boot-learning-2-7-4) -**异步任务** +**异步任务:`@Async`实现** - [Spring Boot 2.x基础教程:使用@Async实现异步任务](https://blog.didispace.com/spring-boot-learning-2-7-5) - [Spring Boot 2.x基础教程:配置@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-6) @@ -128,7 +131,11 @@ ## 我的公众号 - + + +## 推荐我的书 + +![Spring Boot微服务实战](https://git.oschina.net/uploads/images/2017/0416/233656_dd3bce94_437188.png) ## 特别赞助商 diff --git a/2.x/README_zh.md b/2.x/README_zh.md index 0f3471d0..aed820b3 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -7,6 +7,7 @@ **加入社群**:[如果你正在学习Spring Boot,不妨加入我们的Spring技术交流群,一起成长!](https://blog.didispace.com/join-group-spring/index.html) **如何支持**: + 1. 关注我的公众号”**程序猿DD**“ 2. 点个`Star`并`Follow`我 3. 把该仓库分享给更多的朋友 @@ -85,14 +86,17 @@ ### 任务管理 -**定时任务** +**定时任务:`@Scheduled`实现** - [Spring Boot 2.x基础教程:使用@Scheduled实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-1) + +**定时任务:Elastic Job实现** + - [Spring Boot 2.x基础教程:使用Elastic Job实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-2) - [Spring Boot 2.x基础教程:使用Elastic Job的分片配置提高执行效率](https://blog.didispace.com/spring-boot-learning-2-7-3) - [Spring Boot 2.x基础教程:使用Elastic Job的namespace防止任务名冲突](https://blog.didispace.com/spring-boot-learning-2-7-4) -**异步任务** +**异步任务:`@Async`实现** - [Spring Boot 2.x基础教程:使用@Async实现异步任务](https://blog.didispace.com/spring-boot-learning-2-7-5) - [Spring Boot 2.x基础教程:配置@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-6) @@ -136,11 +140,11 @@ ## 我的公众号 - + ## 推荐我的书 -![](https://git.oschina.net/uploads/images/2017/0416/233656_dd3bce94_437188.png "在这里输入图片标题") +![Spring Boot微服务实战](https://git.oschina.net/uploads/images/2017/0416/233656_dd3bce94_437188.png) ## 特别赞助商 From 34c2eb96f3b5000da2443cb253f95fd0c693552b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Fri, 29 Oct 2021 14:52:52 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 32 ++++++---- 2.x/README_zh.md | 32 ++++++---- 2.x/chapter4-5/pom.xml | 63 +++++++++++++++++++ .../com/didispace/chapter45/Application.java | 22 +++++++ .../didispace/chapter45/HelloController.java | 33 ++++++++++ .../chapter45/WebSecurityConfig.java | 36 +++++++++++ .../src/main/resources/application.properties | 0 .../src/main/resources/templates/hello.html | 13 ++++ .../src/main/resources/templates/index.html | 12 ++++ .../src/main/resources/templates/login.html | 21 +++++++ 2.x/pom.xml | 9 +-- 11 files changed, 243 insertions(+), 30 deletions(-) create mode 100644 2.x/chapter4-5/pom.xml create mode 100644 2.x/chapter4-5/src/main/java/com/didispace/chapter45/Application.java create mode 100644 2.x/chapter4-5/src/main/java/com/didispace/chapter45/HelloController.java create mode 100644 2.x/chapter4-5/src/main/java/com/didispace/chapter45/WebSecurityConfig.java create mode 100644 2.x/chapter4-5/src/main/resources/application.properties create mode 100644 2.x/chapter4-5/src/main/resources/templates/hello.html create mode 100644 2.x/chapter4-5/src/main/resources/templates/index.html create mode 100644 2.x/chapter4-5/src/main/resources/templates/login.html diff --git a/2.x/README.md b/2.x/README.md index 94e15452..eb25e406 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -14,20 +14,20 @@ ## 教程目录(2.x版本) -连载中...Star关注支持一下,随时获得更新信息! +本教程内容持续更新连载中!**Star关注**支持一下,随时获得更新信息! -### 基础知识 +### 快速入门 - [Spring Boot 2.x基础教程:版本关系](http://blog.didispace.com/spring-cloud-alibaba-version/) - [Spring Boot 2.x基础教程:快速入门](http://blog.didispace.com/spring-boot-learning-21-1-1/) - [Spring Boot 2.x基础教程:工程结构推荐](http://blog.didispace.com/spring-boot-learning-21-1-2/) -### 配置文件 +### 配置详解 - [Spring Boot 2.x基础教程:配置文件详解](http://blog.didispace.com/spring-boot-learning-21-1-3/) -- [Spring Boot 2.x基础教程:配置元数据的应用 ](http://blog.didispace.com/spring-boot-learning-24-1-6/) - [Spring Boot 2.x基础教程:2.4版本前后的多环境配置变化](http://blog.didispace.com/spring-boot-learning-24-1-4/) - [Spring Boot 2.x基础教程:2.4版本前后的分组配置变化](http://blog.didispace.com/spring-boot-learning-24-1-5/) +- [Spring Boot 2.x基础教程:配置元数据的应用 ](http://blog.didispace.com/spring-boot-learning-24-1-6/) - [Spring Boot 2.x基础教程:加密配置中的敏感信息](http://blog.didispace.com/spring-boot-learning-2-1-5/) ### API开发 @@ -56,7 +56,7 @@ - [Spring Boot 2.x基础教程:MyBatis的多数据源配置](http://blog.didispace.com/spring-boot-learning-21-3-9/) - [Spring Boot 2.x基础教程:事务管理入门](http://blog.didispace.com/spring-boot-learning-21-3-10/) - [Spring Boot 2.x基础教程:使用Flyway管理数据库版本](http://blog.didispace.com/spring-boot-learning-24-3-11/) -- [Spring Boot 2.x基础教程:使用JTA实现分布式事务](http://blog.didispace.com/spring-boot-learning-24-3-12/) +- [Spring Boot 2.x基础教程:使用JTA实现多数据源的事务管理](http://blog.didispace.com/spring-boot-learning-24-3-12/) - [Spring Boot 2.x基础教程:2.5版本后数据脚本初始化的变动](http://blog.didispace.com/spring-boot-learning-25-3-13/) **加速利器:各种缓存的使用** @@ -79,34 +79,40 @@ - [Spring Boot 2.x基础教程:使用 Thymeleaf开发Web页面](http://blog.didispace.com/spring-boot-learning-21-4-1/) - [Spring Boot 2.x基础教程:使用 ECharts 绘制各种华丽的数据图表](http://blog.didispace.com/spring-boot-learning-21-4-2/) - [Spring Boot 2.x基础教程:实现文件上传](http://blog.didispace.com/spring-boot-learning-21-4-3/) -- [Spring Boot 2.x基础教程:实现多文件上传](http://blog.didispace.com/spring-boot-learning-21-4-4/) -- [Spring Boot 2.x基础教程:文件上传的单元测试怎么写](https://blog.didispace.com/spring-boot-learning-21-4-5/) +- [Spring Boot 2.x基础教程:多个文件的上传](http://blog.didispace.com/spring-boot-learning-21-4-4/) +- [Spring Boot 2.x基础教程:文件上传的单元测试怎么写](http://blog.didispace.com/spring-boot-learning-21-4-5/) ### 任务管理 -**定时任务:`@Scheduled`实现** +**定时任务** - [Spring Boot 2.x基础教程:使用@Scheduled实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-1) - -**定时任务:Elastic Job实现** - - [Spring Boot 2.x基础教程:使用Elastic Job实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-2) - [Spring Boot 2.x基础教程:使用Elastic Job的分片配置提高执行效率](https://blog.didispace.com/spring-boot-learning-2-7-3) - [Spring Boot 2.x基础教程:使用Elastic Job的namespace防止任务名冲突](https://blog.didispace.com/spring-boot-learning-2-7-4) -**异步任务:`@Async`实现** +**异步任务** - [Spring Boot 2.x基础教程:使用@Async实现异步任务](https://blog.didispace.com/spring-boot-learning-2-7-5) - [Spring Boot 2.x基础教程:配置@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-6) - [Spring Boot 2.x基础教程:如何隔离@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-7) - [Spring Boot 2.x基础教程:配置线程池的拒绝策略](https://blog.didispace.com/spring-boot-learning-2-7-8) -### 常见问题 +### 其他内容 + +- [Spring Boot自定义启动Banner](http://blog.didispace.com/spring-boot-banner/) +- [实现邮件发送:简单邮件、附件邮件、嵌入资源的邮件、模板邮件](http://blog.didispace.com/springbootmailsender/) +- [使用Spring StateMachine框架实现状态机](http://blog.didispace.com/spring-statemachine/) +- [Spring Boot应用的后台运行配置](http://blog.didispace.com/spring-boot-run-backend/) + + +## 问题与思考 - [为什么加了@Transactional注解,事务没有回滚?](http://blog.didispace.com/transactional-not-rollback/) - [为什么启动时候API路径都没了?](http://blog.didispace.com/spring-boot-learning-21-2-6/) - [使用Java 8中LocalDate等时间日期类的问题解决](http://blog.didispace.com/Spring-Boot-And-Feign-Use-localdate/) - [Request header is too large 如何解决?](https://blog.didispace.com/request-header-is-too-large/) +- [Spring Boot自动化配置的利弊及解决之道](http://blog.didispace.com/spring-boot-disable-autoconfig/) ## 版本资讯 diff --git a/2.x/README_zh.md b/2.x/README_zh.md index aed820b3..256943c1 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -16,20 +16,20 @@ ## 教程目录(2.x版本) -连载中...Star关注支持一下,随时获得更新信息! +本教程内容持续更新连载中!**Star关注**支持一下,随时获得更新信息! -### 基础知识 +### 快速入门 - [Spring Boot 2.x基础教程:版本关系](http://blog.didispace.com/spring-cloud-alibaba-version/) - [Spring Boot 2.x基础教程:快速入门](http://blog.didispace.com/spring-boot-learning-21-1-1/) - [Spring Boot 2.x基础教程:工程结构推荐](http://blog.didispace.com/spring-boot-learning-21-1-2/) -### 配置文件 +### 配置详解 - [Spring Boot 2.x基础教程:配置文件详解](http://blog.didispace.com/spring-boot-learning-21-1-3/) -- [Spring Boot 2.x基础教程:配置元数据的应用 ](http://blog.didispace.com/spring-boot-learning-24-1-6/) - [Spring Boot 2.x基础教程:2.4版本前后的多环境配置变化](http://blog.didispace.com/spring-boot-learning-24-1-4/) - [Spring Boot 2.x基础教程:2.4版本前后的分组配置变化](http://blog.didispace.com/spring-boot-learning-24-1-5/) +- [Spring Boot 2.x基础教程:配置元数据的应用 ](http://blog.didispace.com/spring-boot-learning-24-1-6/) - [Spring Boot 2.x基础教程:加密配置中的敏感信息](http://blog.didispace.com/spring-boot-learning-2-1-5/) ### API开发 @@ -58,7 +58,7 @@ - [Spring Boot 2.x基础教程:MyBatis的多数据源配置](http://blog.didispace.com/spring-boot-learning-21-3-9/) - [Spring Boot 2.x基础教程:事务管理入门](http://blog.didispace.com/spring-boot-learning-21-3-10/) - [Spring Boot 2.x基础教程:使用Flyway管理数据库版本](http://blog.didispace.com/spring-boot-learning-24-3-11/) -- [Spring Boot 2.x基础教程:使用JTA实现分布式事务](http://blog.didispace.com/spring-boot-learning-24-3-12/) +- [Spring Boot 2.x基础教程:使用JTA实现多数据源的事务管理](http://blog.didispace.com/spring-boot-learning-24-3-12/) - [Spring Boot 2.x基础教程:2.5版本后数据脚本初始化的变动](http://blog.didispace.com/spring-boot-learning-25-3-13/) **加速利器:各种缓存的使用** @@ -81,34 +81,40 @@ - [Spring Boot 2.x基础教程:使用 Thymeleaf开发Web页面](http://blog.didispace.com/spring-boot-learning-21-4-1/) - [Spring Boot 2.x基础教程:使用 ECharts 绘制各种华丽的数据图表](http://blog.didispace.com/spring-boot-learning-21-4-2/) - [Spring Boot 2.x基础教程:实现文件上传](http://blog.didispace.com/spring-boot-learning-21-4-3/) -- [Spring Boot 2.x基础教程:实现多文件上传](http://blog.didispace.com/spring-boot-learning-21-4-4/) -- [Spring Boot 2.x基础教程:文件上传的单元测试怎么写](https://blog.didispace.com/spring-boot-learning-21-4-5/) +- [Spring Boot 2.x基础教程:多个文件的上传](http://blog.didispace.com/spring-boot-learning-21-4-4/) +- [Spring Boot 2.x基础教程:文件上传的单元测试怎么写](http://blog.didispace.com/spring-boot-learning-21-4-5/) ### 任务管理 -**定时任务:`@Scheduled`实现** +**定时任务** - [Spring Boot 2.x基础教程:使用@Scheduled实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-1) - -**定时任务:Elastic Job实现** - - [Spring Boot 2.x基础教程:使用Elastic Job实现定时任务](https://blog.didispace.com/spring-boot-learning-2-7-2) - [Spring Boot 2.x基础教程:使用Elastic Job的分片配置提高执行效率](https://blog.didispace.com/spring-boot-learning-2-7-3) - [Spring Boot 2.x基础教程:使用Elastic Job的namespace防止任务名冲突](https://blog.didispace.com/spring-boot-learning-2-7-4) -**异步任务:`@Async`实现** +**异步任务** - [Spring Boot 2.x基础教程:使用@Async实现异步任务](https://blog.didispace.com/spring-boot-learning-2-7-5) - [Spring Boot 2.x基础教程:配置@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-6) - [Spring Boot 2.x基础教程:如何隔离@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-7) - [Spring Boot 2.x基础教程:配置线程池的拒绝策略](https://blog.didispace.com/spring-boot-learning-2-7-8) -### 常见问题 +### 其他内容 + +- [Spring Boot自定义启动Banner](http://blog.didispace.com/spring-boot-banner/) +- [实现邮件发送:简单邮件、附件邮件、嵌入资源的邮件、模板邮件](http://blog.didispace.com/springbootmailsender/) +- [使用Spring StateMachine框架实现状态机](http://blog.didispace.com/spring-statemachine/) +- [Spring Boot应用的后台运行配置](http://blog.didispace.com/spring-boot-run-backend/) + + +## 问题与思考 - [为什么加了@Transactional注解,事务没有回滚?](http://blog.didispace.com/transactional-not-rollback/) - [为什么启动时候API路径都没了?](http://blog.didispace.com/spring-boot-learning-21-2-6/) - [使用Java 8中LocalDate等时间日期类的问题解决](http://blog.didispace.com/Spring-Boot-And-Feign-Use-localdate/) - [Request header is too large 如何解决?](https://blog.didispace.com/request-header-is-too-large/) +- [Spring Boot自动化配置的利弊及解决之道](http://blog.didispace.com/spring-boot-disable-autoconfig/) ## 版本资讯 diff --git a/2.x/chapter4-5/pom.xml b/2.x/chapter4-5/pom.xml new file mode 100644 index 00000000..7120c77a --- /dev/null +++ b/2.x/chapter4-5/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.5.1 + + + + com.didispace + chapter4-5 + 0.0.1-SNAPSHOT + Spring Security快速入门 + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-security + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/2.x/chapter4-5/src/main/java/com/didispace/chapter45/Application.java b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/Application.java new file mode 100644 index 00000000..00d2d076 --- /dev/null +++ b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/Application.java @@ -0,0 +1,22 @@ +package com.didispace.chapter45; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * + * @author 程序猿DD + * @version 1.0.0 + * @blog http://blog.didispace.com + * + */ +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + + SpringApplication.run(Application.class, args); + + } + +} diff --git a/2.x/chapter4-5/src/main/java/com/didispace/chapter45/HelloController.java b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/HelloController.java new file mode 100644 index 00000000..849a125d --- /dev/null +++ b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/HelloController.java @@ -0,0 +1,33 @@ +package com.didispace.chapter45; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * + * @author 程序猿DD + * @version 1.0.0 + * @blog http://blog.didispace.com + * + */ +@Controller +public class HelloController { + + @RequestMapping("/") + public String index() { + return "index"; + } + + @RequestMapping("/hello") + public String hello() { + return "hello"; + } + + @RequestMapping(value = "/login", method = RequestMethod.GET) + public String login() { + return "login"; + } + +} \ No newline at end of file diff --git a/2.x/chapter4-5/src/main/java/com/didispace/chapter45/WebSecurityConfig.java b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/WebSecurityConfig.java new file mode 100644 index 00000000..30fffef5 --- /dev/null +++ b/2.x/chapter4-5/src/main/java/com/didispace/chapter45/WebSecurityConfig.java @@ -0,0 +1,36 @@ +package com.didispace.chapter45; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/", "/home").permitAll() + .anyRequest().authenticated() + .and() + .formLogin() + .loginPage("/login") + .permitAll() + .and() + .logout() + .permitAll(); + } + + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + auth + .inMemoryAuthentication() + .withUser("user").password("password").roles("USER"); + } + +} \ No newline at end of file diff --git a/2.x/chapter4-5/src/main/resources/application.properties b/2.x/chapter4-5/src/main/resources/application.properties new file mode 100644 index 00000000..e69de29b diff --git a/2.x/chapter4-5/src/main/resources/templates/hello.html b/2.x/chapter4-5/src/main/resources/templates/hello.html new file mode 100644 index 00000000..51477131 --- /dev/null +++ b/2.x/chapter4-5/src/main/resources/templates/hello.html @@ -0,0 +1,13 @@ + + + + Hello World! + + +

Hello [[${#httpServletRequest.remoteUser}]]!

+
+ +
+ + \ No newline at end of file diff --git a/2.x/chapter4-5/src/main/resources/templates/index.html b/2.x/chapter4-5/src/main/resources/templates/index.html new file mode 100644 index 00000000..ffe28340 --- /dev/null +++ b/2.x/chapter4-5/src/main/resources/templates/index.html @@ -0,0 +1,12 @@ + + + + Spring Security入门 + + +

欢迎使用Spring Security!

+ +

点击 这里 打个招呼吧

+ + \ No newline at end of file diff --git a/2.x/chapter4-5/src/main/resources/templates/login.html b/2.x/chapter4-5/src/main/resources/templates/login.html new file mode 100644 index 00000000..f5cbe8e2 --- /dev/null +++ b/2.x/chapter4-5/src/main/resources/templates/login.html @@ -0,0 +1,21 @@ + + + + Spring Security Example + + +
+ 用户名或密码错 +
+
+ 您已注销成功 +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/2.x/pom.xml b/2.x/pom.xml index 4c21f4b1..947e5fea 100644 --- a/2.x/pom.xml +++ b/2.x/pom.xml @@ -54,7 +54,7 @@ chapter4-2 chapter4-3 chapter4-4 - + chapter4-5 chapter5-1 @@ -62,7 +62,7 @@ chapter5-3 chapter5-4 chapter5-5 - + chapter6-1 @@ -82,8 +82,9 @@ chapter7-8 - - chapter8-1 + + + From 8f6234f4faffd2c44c358b58e67390e49ac1eaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Tue, 9 Nov 2021 15:11:29 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 3 ++- 2.x/README_zh.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/2.x/README.md b/2.x/README.md index eb25e406..3facb5e3 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -106,8 +106,9 @@ - [Spring Boot应用的后台运行配置](http://blog.didispace.com/spring-boot-run-backend/) -## 问题与思考 +## 进阶与深入 +- [什么时候不要使用@Autowire](http://blog.didispace.com/when-not-use-autowire-in-spring-boot/) - [为什么加了@Transactional注解,事务没有回滚?](http://blog.didispace.com/transactional-not-rollback/) - [为什么启动时候API路径都没了?](http://blog.didispace.com/spring-boot-learning-21-2-6/) - [使用Java 8中LocalDate等时间日期类的问题解决](http://blog.didispace.com/Spring-Boot-And-Feign-Use-localdate/) diff --git a/2.x/README_zh.md b/2.x/README_zh.md index 256943c1..e7101b86 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -108,8 +108,9 @@ - [Spring Boot应用的后台运行配置](http://blog.didispace.com/spring-boot-run-backend/) -## 问题与思考 +## 进阶与深入 +- [什么时候不要使用@Autowire](http://blog.didispace.com/when-not-use-autowire-in-spring-boot/) - [为什么加了@Transactional注解,事务没有回滚?](http://blog.didispace.com/transactional-not-rollback/) - [为什么启动时候API路径都没了?](http://blog.didispace.com/spring-boot-learning-21-2-6/) - [使用Java 8中LocalDate等时间日期类的问题解决](http://blog.didispace.com/Spring-Boot-And-Feign-Use-localdate/) From e31efa092b63dccec54f68ba8c58e8f405228f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Tue, 14 Dec 2021 12:48:23 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/chapter1-4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.x/chapter1-4/pom.xml b/2.x/chapter1-4/pom.xml index 8c5539f1..5bbd4008 100644 --- a/2.x/chapter1-4/pom.xml +++ b/2.x/chapter1-4/pom.xml @@ -11,7 +11,7 @@ com.didispace chapter1-4 0.0.1-SNAPSHOT - chapter1-1 + chapter1-4 配置元数据的应用 From 5d825367496f6ad9c30510325b92e0e8f25fffb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Tue, 28 Dec 2021 18:28:43 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=8ELogback=E9=85=8D=E7=BD=AE=E8=AF=A6?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 18 ++++------ 2.x/README_zh.md | 6 ++++ 2.x/chapter8-1/pom.xml | 19 +++------- .../com/didispace/chapter81/Application.java | 22 ------------ .../chapter81/Chapter81Application.java | 26 ++++++++++++++ .../didispace/chapter81/HelloController.java | 33 ----------------- .../chapter81/WebSecurityConfig.java | 36 ------------------- .../src/main/resources/application.properties | 14 ++++++++ .../src/main/resources/templates/hello.html | 13 ------- .../src/main/resources/templates/index.html | 12 ------- .../src/main/resources/templates/login.html | 21 ----------- 2.x/pom.xml | 4 +-- 12 files changed, 60 insertions(+), 164 deletions(-) delete mode 100644 2.x/chapter8-1/src/main/java/com/didispace/chapter81/Application.java create mode 100644 2.x/chapter8-1/src/main/java/com/didispace/chapter81/Chapter81Application.java delete mode 100644 2.x/chapter8-1/src/main/java/com/didispace/chapter81/HelloController.java delete mode 100644 2.x/chapter8-1/src/main/java/com/didispace/chapter81/WebSecurityConfig.java delete mode 100644 2.x/chapter8-1/src/main/resources/templates/hello.html delete mode 100644 2.x/chapter8-1/src/main/resources/templates/index.html delete mode 100644 2.x/chapter8-1/src/main/resources/templates/login.html diff --git a/2.x/README.md b/2.x/README.md index 3facb5e3..59541053 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -98,6 +98,12 @@ - [Spring Boot 2.x基础教程:如何隔离@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-7) - [Spring Boot 2.x基础教程:配置线程池的拒绝策略](https://blog.didispace.com/spring-boot-learning-2-7-8) +### 日志管理 + +- [Spring Boot 2.x基础教程:默认日志管理与Logback配置详解](https://blog.didispace.com/spring-boot-learning-2-8-1) +- [Spring Boot 2.x基础教程:使用tinylog记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) +- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) + ### 其他内容 - [Spring Boot自定义启动Banner](http://blog.didispace.com/spring-boot-banner/) @@ -105,7 +111,6 @@ - [使用Spring StateMachine框架实现状态机](http://blog.didispace.com/spring-statemachine/) - [Spring Boot应用的后台运行配置](http://blog.didispace.com/spring-boot-run-backend/) - ## 进阶与深入 - [什么时候不要使用@Autowire](http://blog.didispace.com/when-not-use-autowire-in-spring-boot/) @@ -125,16 +130,7 @@ - [Spring Boot 2.0 新特性(一):配置绑定 2.0 全解析](http://blog.didispace.com/Spring-Boot-2-0-feature-1-relaxed-binding-2/) - [Spring Boot 2.0 新特性(二):新增事件ApplicationStartedEvent](http://blog.didispace.com/Spring-Boot-2-0-feature-2-ApplicationStartedEvent/) -### 2.x版本信息 - -- [Spring Boot 2.2 正式发布,大幅性能提升 + Java 13 支持](http://blog.didispace.com/spring-boot-2-2-release/) -- [Spring Boot 2.3.0 发布](/spring-boot-2-3-0-release/) -- [Spring Boot 2.3.0 放弃 Maven 转投 Gradle](/spring-boot-gradle/) -- [Spring Boot 2.3.2 发布,解决 Too many open files 导致的应用宕机问题](http://blog.didispace.com/spring-boot-2-3-2-release/) -- [Spring Boot 2.4.0 正式发布!全新的配置处理机制,拥抱云原生!](http://blog.didispace.com/spring-boot-2-4-0-ga/) -- [Spring Boot 2.4.1 发布,修正大量2.4全新配置机制的Bug](http://blog.didispace.com/spring-boot-2-4-1-release/) -- [Spring Boot 2.5.0 发布:支持Java16、Gradle 7、Datasource初始化调整](https://blog.didispace.com/spring-boot-2-5-0-release/) -- [Spring Boot 2.5.1 发布](https://blog.didispace.com/spring-boot-2-5-1-release/) +更多关于2.x的版本信息可查看[点击查看](http://www.springcloud.com.cn/) ## 我的公众号 diff --git a/2.x/README_zh.md b/2.x/README_zh.md index e7101b86..3fc0779b 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -100,6 +100,12 @@ - [Spring Boot 2.x基础教程:如何隔离@Async异步任务的线程池](https://blog.didispace.com/spring-boot-learning-2-7-7) - [Spring Boot 2.x基础教程:配置线程池的拒绝策略](https://blog.didispace.com/spring-boot-learning-2-7-8) +### 日志管理 + +- [Spring Boot 2.x基础教程:默认日志管理与Logback配置详解](https://blog.didispace.com/spring-boot-learning-2-8-1) +- [Spring Boot 2.x基础教程:使用tinylog记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) +- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) + ### 其他内容 - [Spring Boot自定义启动Banner](http://blog.didispace.com/spring-boot-banner/) diff --git a/2.x/chapter8-1/pom.xml b/2.x/chapter8-1/pom.xml index 81817f27..d60616ec 100644 --- a/2.x/chapter8-1/pom.xml +++ b/2.x/chapter8-1/pom.xml @@ -13,7 +13,7 @@ com.didispace chapter8-1 0.0.1-SNAPSHOT - Spring Security快速入门 + 默认日志管理与Logback配置详解 UTF-8 @@ -23,7 +23,7 @@ org.springframework.boot - spring-boot-starter + spring-boot-starter-web @@ -33,19 +33,10 @@ - org.springframework.boot - spring-boot-starter-web + org.projectlombok + lombok + provided - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-security - - diff --git a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Application.java b/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Application.java deleted file mode 100644 index f7a9e16e..00000000 --- a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Application.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.didispace; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * - * @author 程序猿DD - * @version 1.0.0 - * @blog http://blog.didispace.com - * - */ -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - - SpringApplication.run(Application.class, args); - - } - -} diff --git a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Chapter81Application.java b/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Chapter81Application.java new file mode 100644 index 00000000..a8fec0e0 --- /dev/null +++ b/2.x/chapter8-1/src/main/java/com/didispace/chapter81/Chapter81Application.java @@ -0,0 +1,26 @@ +package com.didispace.chapter81; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author 程序猿DD + * @version 1.0.0 + * @blog https://blog.didispace.com + */ +@Slf4j +@SpringBootApplication +public class Chapter81Application { + + public static void main(String[] args) { + SpringApplication.run(Chapter81Application.class, args); + + log.error("Hello World"); + log.warn("Hello World"); + log.info("Hello World"); + log.debug("Hello World"); + log.trace("Hello World"); + } + +} diff --git a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/HelloController.java b/2.x/chapter8-1/src/main/java/com/didispace/chapter81/HelloController.java deleted file mode 100644 index f5a6770b..00000000 --- a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/HelloController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.didispace.chapter81; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -/** - * - * @author 程序猿DD - * @version 1.0.0 - * @blog http://blog.didispace.com - * - */ -@Controller -public class HelloController { - - @RequestMapping("/") - public String index() { - return "index"; - } - - @RequestMapping("/hello") - public String hello() { - return "hello"; - } - - @RequestMapping(value = "/login", method = RequestMethod.GET) - public String login() { - return "login"; - } - -} \ No newline at end of file diff --git a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/WebSecurityConfig.java b/2.x/chapter8-1/src/main/java/com/didispace/chapter81/WebSecurityConfig.java deleted file mode 100644 index 1f3da340..00000000 --- a/2.x/chapter8-1/src/main/java/com/didispace/chapter81/WebSecurityConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.didispace.chapter81; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .authorizeRequests() - .antMatchers("/", "/home").permitAll() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .permitAll() - .and() - .logout() - .permitAll(); - } - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth - .inMemoryAuthentication() - .withUser("user").password("password").roles("USER"); - } - -} \ No newline at end of file diff --git a/2.x/chapter8-1/src/main/resources/application.properties b/2.x/chapter8-1/src/main/resources/application.properties index e69de29b..361847c5 100644 --- a/2.x/chapter8-1/src/main/resources/application.properties +++ b/2.x/chapter8-1/src/main/resources/application.properties @@ -0,0 +1,14 @@ +debug=true + +spring.output.ansi.enabled=detect + +logging.file.name=run.log +logging.file.path=./ + +logging.level.com.didispace=debug + +logging.logback.rollingpolicy.clean-history-on-start=false +logging.logback.rollingpolicy.file-name-pattern= +logging.logback.rollingpolicy.max-history=7 +logging.logback.rollingpolicy.max-file-size=10MB +logging.logback.rollingpolicy.total-size-cap=0B diff --git a/2.x/chapter8-1/src/main/resources/templates/hello.html b/2.x/chapter8-1/src/main/resources/templates/hello.html deleted file mode 100644 index 51477131..00000000 --- a/2.x/chapter8-1/src/main/resources/templates/hello.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Hello World! - - -

Hello [[${#httpServletRequest.remoteUser}]]!

-
- -
- - \ No newline at end of file diff --git a/2.x/chapter8-1/src/main/resources/templates/index.html b/2.x/chapter8-1/src/main/resources/templates/index.html deleted file mode 100644 index ffe28340..00000000 --- a/2.x/chapter8-1/src/main/resources/templates/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Spring Security入门 - - -

欢迎使用Spring Security!

- -

点击 这里 打个招呼吧

- - \ No newline at end of file diff --git a/2.x/chapter8-1/src/main/resources/templates/login.html b/2.x/chapter8-1/src/main/resources/templates/login.html deleted file mode 100644 index f5cbe8e2..00000000 --- a/2.x/chapter8-1/src/main/resources/templates/login.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - Spring Security Example - - -
- 用户名或密码错 -
-
- 您已注销成功 -
-
-
-
-
-
- - \ No newline at end of file diff --git a/2.x/pom.xml b/2.x/pom.xml index 947e5fea..664ba7a3 100644 --- a/2.x/pom.xml +++ b/2.x/pom.xml @@ -82,8 +82,8 @@ chapter7-8 - - + + chapter8-1 From 0dd9c71c7cffe65bd0541c02c2c0e284849921a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Wed, 29 Dec 2021 18:02:14 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8log4j2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 3 +- 2.x/README_zh.md | 2 +- 2.x/chapter8-2/pom.xml | 59 +++++++++++++++++++ .../chapter82/Chapter82Application.java | 26 ++++++++ .../src/main/resources/application.properties | 14 +++++ 2.x/pom.xml | 3 +- 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 2.x/chapter8-2/pom.xml create mode 100644 2.x/chapter8-2/src/main/java/com/didispace/chapter82/Chapter82Application.java create mode 100644 2.x/chapter8-2/src/main/resources/application.properties diff --git a/2.x/README.md b/2.x/README.md index 59541053..4c21c833 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -101,8 +101,9 @@ ### 日志管理 - [Spring Boot 2.x基础教程:默认日志管理与Logback配置详解](https://blog.didispace.com/spring-boot-learning-2-8-1) +- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-2) - [Spring Boot 2.x基础教程:使用tinylog记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) -- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) + ### 其他内容 diff --git a/2.x/README_zh.md b/2.x/README_zh.md index 3fc0779b..bc61108c 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -103,8 +103,8 @@ ### 日志管理 - [Spring Boot 2.x基础教程:默认日志管理与Logback配置详解](https://blog.didispace.com/spring-boot-learning-2-8-1) +- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-2) - [Spring Boot 2.x基础教程:使用tinylog记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) -- [Spring Boot 2.x基础教程:使用log4j2记录日志](https://blog.didispace.com/spring-boot-learning-2-8-3) ### 其他内容 diff --git a/2.x/chapter8-2/pom.xml b/2.x/chapter8-2/pom.xml new file mode 100644 index 00000000..fd6eedf7 --- /dev/null +++ b/2.x/chapter8-2/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.1 + + + + com.didispace + chapter8-2 + 0.0.1-SNAPSHOT + 使用log4j2记录日志 + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.projectlombok + lombok + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/2.x/chapter8-2/src/main/java/com/didispace/chapter82/Chapter82Application.java b/2.x/chapter8-2/src/main/java/com/didispace/chapter82/Chapter82Application.java new file mode 100644 index 00000000..be62c0c2 --- /dev/null +++ b/2.x/chapter8-2/src/main/java/com/didispace/chapter82/Chapter82Application.java @@ -0,0 +1,26 @@ +package com.didispace.chapter82; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author 程序猿DD + * @version 1.0.0 + * @blog https://blog.didispace.com + */ +@Slf4j +@SpringBootApplication +public class Chapter82Application { + + public static void main(String[] args) { + SpringApplication.run(Chapter82Application.class, args); + + log.error("Hello World"); + log.warn("Hello World"); + log.info("Hello World"); + log.debug("Hello World"); + log.trace("Hello World"); + } + +} diff --git a/2.x/chapter8-2/src/main/resources/application.properties b/2.x/chapter8-2/src/main/resources/application.properties new file mode 100644 index 00000000..361847c5 --- /dev/null +++ b/2.x/chapter8-2/src/main/resources/application.properties @@ -0,0 +1,14 @@ +debug=true + +spring.output.ansi.enabled=detect + +logging.file.name=run.log +logging.file.path=./ + +logging.level.com.didispace=debug + +logging.logback.rollingpolicy.clean-history-on-start=false +logging.logback.rollingpolicy.file-name-pattern= +logging.logback.rollingpolicy.max-history=7 +logging.logback.rollingpolicy.max-file-size=10MB +logging.logback.rollingpolicy.total-size-cap=0B diff --git a/2.x/pom.xml b/2.x/pom.xml index 664ba7a3..618227a4 100644 --- a/2.x/pom.xml +++ b/2.x/pom.xml @@ -84,7 +84,8 @@ chapter8-1 - + chapter8-2 + From fc1f39b0f842780e5e366ce8226f1865209007b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Thu, 30 Dec 2021 10:59:19 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8log4j2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/chapter8-2/pom.xml | 14 ++++++++++---- .../src/main/resources/application.properties | 14 +------------- 2.x/chapter8-2/src/main/resources/log4j2.xml | 13 +++++++++++++ 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 2.x/chapter8-2/src/main/resources/log4j2.xml diff --git a/2.x/chapter8-2/pom.xml b/2.x/chapter8-2/pom.xml index fd6eedf7..eeda9143 100644 --- a/2.x/chapter8-2/pom.xml +++ b/2.x/chapter8-2/pom.xml @@ -24,12 +24,18 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + - - - - + + org.springframework.boot + spring-boot-starter-log4j2 + org.springframework.boot diff --git a/2.x/chapter8-2/src/main/resources/application.properties b/2.x/chapter8-2/src/main/resources/application.properties index 361847c5..b642e6f9 100644 --- a/2.x/chapter8-2/src/main/resources/application.properties +++ b/2.x/chapter8-2/src/main/resources/application.properties @@ -1,14 +1,2 @@ -debug=true -spring.output.ansi.enabled=detect - -logging.file.name=run.log -logging.file.path=./ - -logging.level.com.didispace=debug - -logging.logback.rollingpolicy.clean-history-on-start=false -logging.logback.rollingpolicy.file-name-pattern= -logging.logback.rollingpolicy.max-history=7 -logging.logback.rollingpolicy.max-file-size=10MB -logging.logback.rollingpolicy.total-size-cap=0B +logging.config=classpath:log4j2.xml \ No newline at end of file diff --git a/2.x/chapter8-2/src/main/resources/log4j2.xml b/2.x/chapter8-2/src/main/resources/log4j2.xml new file mode 100644 index 00000000..18ca1279 --- /dev/null +++ b/2.x/chapter8-2/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + From 6f1bc8f6979d9966c6566201ecd74bd6332f54b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Wed, 9 Feb 2022 15:52:11 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/didispace/chapter14/HelloController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.x/chapter1-4/src/main/java/com/didispace/chapter14/HelloController.java b/2.x/chapter1-4/src/main/java/com/didispace/chapter14/HelloController.java index d19b5ef6..084af5b8 100644 --- a/2.x/chapter1-4/src/main/java/com/didispace/chapter14/HelloController.java +++ b/2.x/chapter1-4/src/main/java/com/didispace/chapter14/HelloController.java @@ -1,4 +1,4 @@ -package com.didispace.chapter11; +package com.didispace.chapter14; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; From 07fd7ad0c11cf443d52ccf47d37f1996d6323341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Wed, 9 Feb 2022 15:57:08 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 3 ++- 2.x/README_zh.md | 3 ++- README.md | 5 +++-- README_zh.md | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/2.x/README.md b/2.x/README.md index 4c21c833..b8940acb 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -4,7 +4,8 @@ **专题目标**:打造全网内容最全,比收费教程更好的Spring Boot免费教程! -**加入社群**:[如果你正在学习Spring Boot,不妨加入我们的Spring技术交流群,一起成长!](https://blog.didispace.com/join-group-spring/index.html) +**加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 +**Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 **如何支持**: diff --git a/2.x/README_zh.md b/2.x/README_zh.md index bc61108c..e0999d9f 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -4,7 +4,8 @@ **专题目标**:打造全网内容最全,比收费教程更好的Spring Boot免费教程! -**加入社群**:[如果你正在学习Spring Boot,不妨加入我们的Spring技术交流群,一起成长!](https://blog.didispace.com/join-group-spring/index.html) +**加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 +**Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 **如何支持**: diff --git a/README.md b/README.md index 84dea730..2bb8edeb 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ 2. 点个`Star`并`Follow`我 3. 把该仓库分享给更多的朋友 -**加入社群**:[如果你正在学习Spring Boot,不妨加入我们的Spring技术交流群,一起成长!](https://blog.didispace.com/join-group-spring/index.html) +**加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 +**Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 ## 教程目录 该教程自2016年连载至今,因内容较多,经历过多个版本的迭代。 -为方便查看学习,这里重新做了整理,根据1.x版本和2.x版本做了区分汇总。 +为方便查看学习,这里重新做了整理,根据1.x版本和2.x版本做了区分汇总,后续还会继续跟进3.x版本! 可以通过下面的链接,进入具体版本的教程目录: diff --git a/README_zh.md b/README_zh.md index 84dea730..1a7c9110 100644 --- a/README_zh.md +++ b/README_zh.md @@ -8,7 +8,8 @@ 2. 点个`Star`并`Follow`我 3. 把该仓库分享给更多的朋友 -**加入社群**:[如果你正在学习Spring Boot,不妨加入我们的Spring技术交流群,一起成长!](https://blog.didispace.com/join-group-spring/index.html) +**加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 +**Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 ## 教程目录 From fdd6b61af6a0512cc446e05244231dcfc2b8e1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Wed, 9 Feb 2022 15:59:11 +0800 Subject: [PATCH 11/14] =?UTF-8?q?2.x=E7=89=88=E6=9C=AC=E6=95=99=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/README.md | 1 + 2.x/README_zh.md | 1 + README.md | 1 + README_zh.md | 1 + 4 files changed, 4 insertions(+) diff --git a/2.x/README.md b/2.x/README.md index b8940acb..af580d69 100644 --- a/2.x/README.md +++ b/2.x/README.md @@ -5,6 +5,7 @@ **专题目标**:打造全网内容最全,比收费教程更好的Spring Boot免费教程! **加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 + **Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 **如何支持**: diff --git a/2.x/README_zh.md b/2.x/README_zh.md index e0999d9f..70612143 100644 --- a/2.x/README_zh.md +++ b/2.x/README_zh.md @@ -5,6 +5,7 @@ **专题目标**:打造全网内容最全,比收费教程更好的Spring Boot免费教程! **加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 + **Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 **如何支持**: diff --git a/README.md b/README.md index 2bb8edeb..916c7fa4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ 3. 把该仓库分享给更多的朋友 **加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 + **Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 ## 教程目录 diff --git a/README_zh.md b/README_zh.md index 1a7c9110..f75927c3 100644 --- a/README_zh.md +++ b/README_zh.md @@ -9,6 +9,7 @@ 3. 把该仓库分享给更多的朋友 **加入社群**:如果你正在学习Spring Boot,不妨加入我们的[Spring技术交流群](https://blog.didispace.com/join-group-spring/index.html) ,一起成长 + **Spring社区**:如果您在学习过程中碰到问题,可以访问[SpringForAll社区](http://spring4all.com),描述你的问题,我们会尽快给你答复。当然,如果你想分享你的学习经验,也可以在这里发表你的文章 ## 教程目录 From 8d265aa8e12488078752e05aa228a4f321bf52a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Wed, 9 Feb 2022 16:00:11 +0800 Subject: [PATCH 12/14] =?UTF-8?q?1.x=E7=89=88=E6=9C=AC=E6=95=99=E7=A8=8B?= =?UTF-8?q?=EF=BC=88=E5=B7=B2=E5=AE=8C=E7=BB=93=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.x/README.md | 1 + 1.x/README_zh.md | 1 + 2 files changed, 2 insertions(+) diff --git a/1.x/README.md b/1.x/README.md index a1fcc0fe..0fdaf52c 100644 --- a/1.x/README.md +++ b/1.x/README.md @@ -7,6 +7,7 @@ Spring Boot 2.x版本的教程可在`2.x`目录下查看。 + ## 教程目录(1.x版本) 本教程版本基于Spring Boot 1.3.x - 1.5.x,部分内容可能会有出入。如果您发现问题,首先看版本是否一致。如果还有问题,可以提Issue指出。 diff --git a/1.x/README_zh.md b/1.x/README_zh.md index a1fcc0fe..0fdaf52c 100644 --- a/1.x/README_zh.md +++ b/1.x/README_zh.md @@ -7,6 +7,7 @@ Spring Boot 2.x版本的教程可在`2.x`目录下查看。 + ## 教程目录(1.x版本) 本教程版本基于Spring Boot 1.3.x - 1.5.x,部分内容可能会有出入。如果您发现问题,首先看版本是否一致。如果还有问题,可以提Issue指出。 From fbf79267cf97695c6b91eac541ad3df040549e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Fri, 11 Feb 2022 18:51:25 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8tinylog=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/chapter8-3/pom.xml | 60 +++++++++++++++++++ .../chapter83/Chapter83Application.java | 26 ++++++++ .../src/main/resources/application.properties | 1 + 2.x/pom.xml | 5 +- 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 2.x/chapter8-3/pom.xml create mode 100644 2.x/chapter8-3/src/main/java/com/didispace/chapter83/Chapter83Application.java create mode 100644 2.x/chapter8-3/src/main/resources/application.properties diff --git a/2.x/chapter8-3/pom.xml b/2.x/chapter8-3/pom.xml new file mode 100644 index 00000000..7d640d1a --- /dev/null +++ b/2.x/chapter8-3/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.1 + + + + com.didispace + chapter8-3 + 0.0.1-SNAPSHOT + 使用tinylog记录日志 + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.projectlombok + lombok + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/2.x/chapter8-3/src/main/java/com/didispace/chapter83/Chapter83Application.java b/2.x/chapter8-3/src/main/java/com/didispace/chapter83/Chapter83Application.java new file mode 100644 index 00000000..8a68d462 --- /dev/null +++ b/2.x/chapter8-3/src/main/java/com/didispace/chapter83/Chapter83Application.java @@ -0,0 +1,26 @@ +package com.didispace.chapter83; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author 程序猿DD + * @version 1.0.0 + * @blog https://blog.didispace.com + */ +@Slf4j +@SpringBootApplication +public class Chapter83Application { + + public static void main(String[] args) { + SpringApplication.run(Chapter83Application.class, args); + + log.error("Hello World"); + log.warn("Hello World"); + log.info("Hello World"); + log.debug("Hello World"); + log.trace("Hello World"); + } + +} diff --git a/2.x/chapter8-3/src/main/resources/application.properties b/2.x/chapter8-3/src/main/resources/application.properties new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/2.x/chapter8-3/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/2.x/pom.xml b/2.x/pom.xml index 618227a4..f20e1714 100644 --- a/2.x/pom.xml +++ b/2.x/pom.xml @@ -85,7 +85,10 @@ chapter8-1 chapter8-2 - + chapter8-3 + + + From 4212d163da816c6fa5b28d59130318dac2379a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=8C=BFDD?= Date: Mon, 14 Feb 2022 10:40:01 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8tinylog=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.x/chapter8-3/pom.xml | 27 ++++++++++++++++--- .../src/main/resources/tinylog.properties | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 2.x/chapter8-3/src/main/resources/tinylog.properties diff --git a/2.x/chapter8-3/pom.xml b/2.x/chapter8-3/pom.xml index 7d640d1a..d6a578e8 100644 --- a/2.x/chapter8-3/pom.xml +++ b/2.x/chapter8-3/pom.xml @@ -18,6 +18,7 @@ UTF-8 1.8 + 2.4.1 @@ -33,9 +34,29 @@ - org.springframework.boot - spring-boot-starter-test - test + org.tinylog + tinylog-api + ${tinylog.version} + + + org.tinylog + tinylog-impl + ${tinylog.version} + + + org.tinylog + slf4j-tinylog + ${tinylog.version} + + + org.tinylog + jcl-tinylog + ${tinylog.version} + + + org.tinylog + log4j1.2-api + ${tinylog.version} diff --git a/2.x/chapter8-3/src/main/resources/tinylog.properties b/2.x/chapter8-3/src/main/resources/tinylog.properties new file mode 100644 index 00000000..9eb1b999 --- /dev/null +++ b/2.x/chapter8-3/src/main/resources/tinylog.properties @@ -0,0 +1,2 @@ +writer=console +writer.format={date: HH:mm:ss.SSS} {level}: {message} \ No newline at end of file