Skip to content

aaa #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 266 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
266 commits
Select commit Hold shift + click to select a range
a2d33c0
Spring Boot以及Feign使用Java 8中LocalDate等时间日期类的问题解决
dyc87112 Mar 13, 2018
abc8dfd
Spring Boot以及Feign使用Java 8中LocalDate等时间日期类的问题解决
dyc87112 Mar 14, 2018
aa27767
Spring Boot中增强对MongoDB的配置(连接池等)
dyc87112 Mar 18, 2018
f747d43
工程整理
dyc87112 Mar 20, 2018
660c0c8
使用Redis做集中式缓存
dyc87112 Mar 21, 2018
fd635d9
使用@Async实现异步调用:自定义线程池
dyc87112 Mar 22, 2018
4bf616e
使用@Async实现异步调用:资源优雅关闭
dyc87112 Mar 22, 2018
4b0af6f
更新目录
dyc87112 Mar 27, 2018
7dbc34e
使用@Async实现异步调用:使用Future
dyc87112 Apr 15, 2018
88d49d7
update
dyc87112 Apr 15, 2018
268dfdf
扩展XML请求和响应的支持
dyc87112 Sep 22, 2018
33dc0e3
扩展XML请求和响应的支持
dyc87112 Sep 22, 2018
1c78b86
扩展XML请求和响应的支持
dyc87112 Sep 22, 2018
4f23531
Update README.md
dyc87112 Jan 13, 2019
5ec2a3b
Update README.md
dyc87112 Jan 13, 2019
6f0b97d
Update README.md
dyc87112 Jan 13, 2019
30a42ef
Update README.md
dyc87112 Jan 13, 2019
a6d7c42
Update README.md
dyc87112 Jan 13, 2019
d25417a
上传素材
dyc87112 Mar 19, 2019
f9c2bbb
update
dyc87112 Mar 19, 2019
0d7ee54
update
dyc87112 Mar 19, 2019
e46e349
update
dyc87112 Mar 19, 2019
b58ea1e
update
dyc87112 Mar 19, 2019
5cae04d
update
dyc87112 Mar 19, 2019
50fd61a
update
dyc87112 Mar 19, 2019
e92feb6
update
dyc87112 Mar 19, 2019
a3adf8e
update
dyc87112 Mar 19, 2019
b7eb86a
update
dyc87112 Mar 19, 2019
5fe134a
update
dyc87112 Mar 19, 2019
7ed7eb7
update
dyc87112 Mar 19, 2019
e3ab1d1
update
dyc87112 Mar 19, 2019
00923fa
update
dyc87112 Mar 19, 2019
b72f669
Update README.md
dyc87112 Mar 19, 2019
59a1d92
Update README.md
dyc87112 Mar 20, 2019
7a8f3bb
Update README.md
dyc87112 Mar 20, 2019
6761427
Update README.md
dyc87112 Mar 20, 2019
c1d0a0a
Update README.md
dyc87112 Mar 21, 2019
3a425d4
Update README.md
dyc87112 Mar 24, 2019
61a12bc
Update README.md
dyc87112 Mar 25, 2019
33fae15
Update README.md
dyc87112 Apr 15, 2019
90719a6
update
dyc87112 Apr 22, 2019
f771c85
清理master下的代码例子,原来的内容分别根据spring boot的版本做迁移,1.x内容移到1.x分支,2.x内容移到2.x分支
dyc87112 Apr 22, 2019
344eb9b
update
dyc87112 May 31, 2019
5a8e614
update
dyc87112 May 31, 2019
d5270b1
update
dyc87112 May 31, 2019
76f9d0e
update
dyc87112 May 31, 2019
e77b8e4
update
dyc87112 May 31, 2019
ca9cc36
Update README.md
dyc87112 Jun 5, 2019
a83af16
Update README.md
dyc87112 Jul 17, 2019
3c8139e
Update README_zh.md
dyc87112 Jul 18, 2019
29910fb
Update README.md
dyc87112 Sep 22, 2019
62dc20a
Update README_zh.md
dyc87112 Sep 22, 2019
79de538
update
dyc87112 Sep 27, 2019
deb3e37
Update README.md
dyc87112 Oct 24, 2019
ff8187b
Update README_zh.md
dyc87112 Oct 24, 2019
f5969e3
Update README.md
dyc87112 Dec 13, 2019
89828ba
Update README.md
dyc87112 Jan 10, 2020
e260697
Update README.md
dyc87112 Jan 10, 2020
7f121d4
Update README.md
dyc87112 Jan 10, 2020
c55e8d4
Update README.md
dyc87112 Jan 10, 2020
20e3e26
Update README.md
dyc87112 Jan 10, 2020
f9d438f
Update README_zh.md
dyc87112 Jan 10, 2020
e595fd5
update
dyc87112 Jan 22, 2020
2daf17a
Merge remote-tracking branch 'origin/master'
dyc87112 Jan 22, 2020
0468e30
update
dyc87112 Jan 22, 2020
61f289b
update
dyc87112 Jan 22, 2020
ade3b12
update
dyc87112 Jan 22, 2020
765af2d
update
dyc87112 Jan 22, 2020
fffaee8
update
dyc87112 Jan 22, 2020
461e8e8
Spring Boot 2.x基础教程:使用JdbcTemplate访问MySQL数据库
dyc87112 Jan 22, 2020
7daf565
Spring Boot 2.x基础教程:使用JdbcTemplate访问MySQL数据库
dyc87112 Jan 22, 2020
d4fef7d
Spring Boot 2.x基础教程:使用JdbcTemplate访问MySQL数据库
dyc87112 Jan 23, 2020
caaa3fe
update
dyc87112 Feb 3, 2020
f05d815
Spring Boot 2.x基础教程:使用JdbcTemplate访问MySQL数据库
dyc87112 Feb 5, 2020
e4ef2fe
Spring Boot 2.x基础教程:默认数据源Hikari的配置详解
dyc87112 Feb 5, 2020
9f71244
Spring Boot 2.x基础教程:使用国产数据库连接池Druid
dyc87112 Feb 8, 2020
dc66a4a
update
dyc87112 Feb 8, 2020
8e818a8
Spring Boot 2.x基础教程:找回启动日志中的请求路径列表
dyc87112 Feb 12, 2020
883d9ca
Spring Boot 2.x基础教程:使用Spring Data JPA访问MySQL
dyc87112 Feb 15, 2020
5a75730
Spring Boot 2.x基础教程:使用Thymeleaf开发Web页面
dyc87112 Feb 21, 2020
1162d0f
Spring Boot 2.x基础教程:使用 ECharts 绘制折线图
dyc87112 Feb 21, 2020
5a198a4
更新目录
dyc87112 Feb 21, 2020
815e219
update
dyc87112 Feb 22, 2020
77a4c13
更新目录
dyc87112 Feb 23, 2020
1cf9b2a
Spring Boot 2.x基础教程:使用MyBatis访问MySQL
dyc87112 Feb 27, 2020
b5b48e2
Spring Boot 2.x基础教程:使用MyBatis访问MySQL
dyc87112 Feb 28, 2020
1ac7489
Spring Boot 2.x基础教程:使用MyBatis的XML配置方式
dyc87112 Feb 28, 2020
97df90b
Spring Boot 2.x基础教程:使用MyBatis的XML配置方式
dyc87112 Feb 28, 2020
fb27670
update
dyc87112 Feb 28, 2020
5c6d085
Update README.md
dyc87112 Mar 17, 2020
eb9b06e
update
dyc87112 Apr 21, 2020
f5f1192
update
dyc87112 May 20, 2020
2ccecba
Spring Boot 2.x基础教程:JdbcTemplate的多数据源配置
dyc87112 Jun 19, 2020
e2fc129
Spring Boot 2.x基础教程:JdbcTemplate的多数据源配置
dyc87112 Jun 19, 2020
5f80be5
doing
dyc87112 Jun 19, 2020
78eaaf4
doing
dyc87112 Jun 19, 2020
6d06a02
Spring Data JPA的多数据源配置
dyc87112 Jun 21, 2020
5615863
Spring Boot 2.x基础教程:Spring Data JPA的多数据源配置
dyc87112 Jun 22, 2020
cc1771d
Spring Boot 2.x基础教程:MyBatis的多数据源配置
dyc87112 Jun 24, 2020
c7e5aa2
Spring Boot 2.x基础教程:MyBatis的多数据源配置
dyc87112 Jun 24, 2020
388c338
Spring Boot 2.x基础教程:MyBatis的多数据源配置
dyc87112 Jun 24, 2020
a0fa87a
Spring Boot 2.x基础教程:事务管理入门
dyc87112 Jul 9, 2020
c0bd348
更新目录
dyc87112 Jul 9, 2020
fb4c739
Spring Boot 2.x基础教程:进程内缓存的使用与Cache注解详解
dyc87112 Jul 14, 2020
b6e21fb
Spring Boot 2.x基础教程:EhCache缓存的使用
dyc87112 Jul 15, 2020
0b625fb
更新目录
dyc87112 Jul 16, 2020
0c4a3af
Spring Boot 2.x基础教程:使用EhCache缓存集群
dyc87112 Jul 16, 2020
9ccc10e
Spring Boot 2.x基础教程:使用EhCache缓存集群
dyc87112 Jul 16, 2020
f65e3e0
Spring Boot 2.x基础教程:使用EhCache缓存集群
dyc87112 Jul 16, 2020
71fa1bc
Spring Boot 2.x基础教程:使用SpringFox3生成Swagger文档
dyc87112 Jul 16, 2020
fc7fb95
Spring Boot 2.x基础教程:使用集中式缓存Redis
dyc87112 Jul 26, 2020
bcfd83b
Spring Boot 2.x基础教程:使用集中式缓存Redis
dyc87112 Jul 26, 2020
3147a0f
Spring Boot 2.x基础教程:使用集中式缓存Redis
dyc87112 Jul 26, 2020
fb55493
Spring Boot 2.x基础教程:使用集中式缓存Redis
dyc87112 Aug 12, 2020
dc2b430
更新目录
dyc87112 Aug 12, 2020
5974053
update
dyc87112 Aug 20, 2020
350f834
update
dyc87112 Aug 20, 2020
68da1cc
update
dyc87112 Aug 20, 2020
4c8f2b6
Update README.md
dyc87112 Aug 20, 2020
c4e6bfe
Update README.md
dyc87112 Aug 20, 2020
967f243
update
dyc87112 Aug 26, 2020
de135b1
Update README.md
dyc87112 Oct 30, 2020
322fc7b
Update README.md
dyc87112 Oct 30, 2020
e11ae1f
Update README.md
dyc87112 Oct 30, 2020
707f93e
Update README.md
dyc87112 Nov 26, 2020
a24e665
Update README.md
dyc87112 Nov 26, 2020
a48e2cb
2.1.x内容并入2.x
dyc87112 Dec 16, 2020
7f20319
2.1.x内容并入2.x
dyc87112 Dec 16, 2020
f66a3f3
2.1.x内容并入2.x
dyc87112 Dec 16, 2020
0f79b37
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
e2b4f3c
images
dyc87112 Dec 16, 2020
5b645ff
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
4bd0e0c
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
3bc79d1
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
065a6cb
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
3636713
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
7d9d2e2
Spring Boot 2.4 多环境配置支持的变更
dyc87112 Dec 16, 2020
ee97ad8
Spring Boot 2.4 版本前后的配置分组功能
dyc87112 Dec 17, 2020
73a7148
Spring Boot 2.4 版本前后的配置分组功能
dyc87112 Dec 17, 2020
e61e564
Spring Boot 2.4 版本前后的配置分组功能
dyc87112 Dec 18, 2020
5cb0e98
Spring Boot 2.x基础教程:实现文件上传
dyc87112 Dec 30, 2020
bb70a13
Spring Boot 2.x基础教程:实现多文件上传
dyc87112 Dec 30, 2020
9de6fcc
Spring Boot 2.x基础教程:实现文件上传
dyc87112 Jan 6, 2021
f767a48
Spring Boot 2.x基础教程:实现文件上传
dyc87112 Jan 6, 2021
fff0221
Spring Boot 2.x基础教程:实现多个文件的上传
dyc87112 Jan 6, 2021
ff2141d
Spring Boot 2.x基础教程:多个文件的上传
dyc87112 Jan 6, 2021
d3d5c80
使用Flyway管理数据库版本
dyc87112 Jan 11, 2021
4b7b971
增加一些说明
dyc87112 Jan 13, 2021
9feedee
增加一些说明
dyc87112 Jan 15, 2021
787aa90
update
dyc87112 Jan 15, 2021
45e0515
Spring Boot 2.x基础教程:配置元数据的应用
dyc87112 Jan 18, 2021
54a27b1
Spring Boot 2.x基础教程:配置元数据的应用
dyc87112 Jan 18, 2021
2b01f8f
Spring Boot 2.x基础教程:使用JTA实现分布式事务
dyc87112 Feb 2, 2021
ef859f7
Spring Boot 2.x基础教程:使用MongoDB
dyc87112 Mar 3, 2021
94ededc
Spring Boot 2.x基础教程:快速入门
dyc87112 Mar 3, 2021
3961ad2
Spring Boot 2.x基础教程:使用MongoDB
dyc87112 Mar 3, 2021
da35cc8
Spring Boot 2.x基础教程:使用MongoDB
dyc87112 Mar 3, 2021
0034376
Spring Boot 2.x基础教程:2.5版本之后的数据脚本初始化
dyc87112 May 23, 2021
aa19c6e
Spring Boot 2.x基础教程:2.5版本后数据脚本初始化的变动
dyc87112 May 23, 2021
5d3fb25
Spring Boot 2.x基础教程:2.5版本后数据脚本初始化的变动
dyc87112 Jun 2, 2021
6c3633e
Spring Boot 2.x基础教程:如何扩展XML格式的请求和响应
dyc87112 Jun 16, 2021
40c3a23
update group
dyc87112 Jun 16, 2021
768fc9f
1
dyc87112 Jun 17, 2021
07bf68a
Spring Boot 2.x基础教程:使用LDAP来管理用户与组织数据
dyc87112 Jun 18, 2021
6ddbfc0
Spring Boot 2.x基础教程:使用Redis的发布订阅功能
dyc87112 Jun 19, 2021
406922e
Spring Boot 2.x基础教程:使用@Scheduled实现定时任务
dyc87112 Jul 13, 2021
ec1c5bb
Spring Boot 2.x基础教程:使用Elastic Job实现定时任务
dyc87112 Jul 20, 2021
aa4a288
Spring Boot 2.x基础教程:使用Elastic Job实现定时任务
dyc87112 Jul 20, 2021
1fe9c48
Spring Boot 2.x基础教程:使用Elastic Job的分片配置
dyc87112 Jul 21, 2021
118290f
Spring Boot 2.x基础教程:使用Elastic Job的分片配置
dyc87112 Jul 21, 2021
44052ed
构建RESTful API与单元测试
dyc87112 Jul 22, 2021
f745d84
使用Swagger2构建强大的API文档
dyc87112 Jul 22, 2021
45743a4
使用JSR-303实现请求参数校验
dyc87112 Jul 22, 2021
fa96338
配置元数据的应用
dyc87112 Jul 22, 2021
1611c4c
2.4版本前后的配置分组配置
dyc87112 Jul 22, 2021
cbb4892
2.4版本前后的多环境配置与配置激活
dyc87112 Jul 22, 2021
b0e82ae
快速入门
dyc87112 Jul 22, 2021
a52c050
Swagger接口分类与各元素排序问题详解
dyc87112 Jul 22, 2021
6ac4845
Swagger静态文档的生成
dyc87112 Jul 22, 2021
6c797ff
找回启动日志中的请求路径列表
dyc87112 Jul 22, 2021
cf654dc
使用SpringFox3生成Swagger文档
dyc87112 Jul 22, 2021
7e55b34
如何扩展XML格式的请求和响应
dyc87112 Jul 22, 2021
bd19eb2
使用JdbcTemplate访问MySQL数据库
dyc87112 Jul 22, 2021
ee86666
默认数据源Hikari的配置详解
dyc87112 Jul 22, 2021
aada619
使用国产数据库连接池Druid
dyc87112 Jul 22, 2021
dcdbce7
使用Spring Data JPA访问MySQL
dyc87112 Jul 22, 2021
bc1798e
使用MyBatis访问MySQL
dyc87112 Jul 22, 2021
4e3ec31
使用MyBatis(xml配置方式)
dyc87112 Jul 22, 2021
401b9e6
JdbcTemplate的多数据源配置
dyc87112 Jul 22, 2021
9643954
Spring Data JPA的多数据源配置
dyc87112 Jul 22, 2021
3cf1468
MyBatis的多数据源配置
dyc87112 Jul 22, 2021
2533d8e
事务管理入门
dyc87112 Jul 22, 2021
f3ee045
使用Flyway管理数据库版本
dyc87112 Jul 22, 2021
d2771e6
使用JTA实现多数据源的事务
dyc87112 Jul 22, 2021
e1769e0
2.5版本之后的数据脚本初始化
dyc87112 Jul 22, 2021
bfcfea3
使用 Thymeleaf开发Web页面
dyc87112 Jul 22, 2021
b91099d
使用 ECharts 绘制折线图
dyc87112 Jul 22, 2021
fda0969
文件上传
dyc87112 Jul 22, 2021
ccdaa07
多文件上传
dyc87112 Jul 22, 2021
559e12c
使用进程内缓存
dyc87112 Jul 22, 2021
fa21d0e
使用进程内缓存 EhCache
dyc87112 Jul 22, 2021
593b19e
使用EhCache缓存集群
dyc87112 Jul 22, 2021
5cd6548
使用集中式缓存Redis
dyc87112 Jul 22, 2021
9dfade9
使用Redis的发布订阅
dyc87112 Jul 22, 2021
9668091
使用MongoDB
dyc87112 Jul 22, 2021
9ab2bd5
使用轻量级树状存储 LDAP
dyc87112 Jul 22, 2021
8b38280
使用@Scheduled实现定时任务
dyc87112 Jul 22, 2021
2823ce1
使用Elastic Job实现定时任务
dyc87112 Jul 22, 2021
648b6d8
使用Elastic Job的分片配置
dyc87112 Jul 22, 2021
5f33cb5
更新目录
dyc87112 Jul 22, 2021
feb99e5
update
dyc87112 Jul 22, 2021
2b89525
更新目录
dyc87112 Jul 22, 2021
134940d
Elastic Job的错误处理策略
dyc87112 Jul 26, 2021
2f1a25f
使用Elastic Job的namespace防止任务名冲突
dyc87112 Jul 28, 2021
6275fa4
update
dyc87112 Jul 28, 2021
a8948d9
使用时序数据库 InfluxDB
dyc87112 Aug 2, 2021
e12aa4f
update
dyc87112 Aug 12, 2021
e440510
update
dyc87112 Aug 13, 2021
b28477a
加密配置文件中的敏感信息
dyc87112 Aug 13, 2021
f52bb67
该目录内容已迁移至2.x目录
dyc87112 Aug 16, 2021
1246efe
1.x教程目录调整
dyc87112 Aug 16, 2021
cc65093
目录优化
dyc87112 Aug 16, 2021
1228430
使用@Async实现异步任务
dyc87112 Aug 26, 2021
679ebf6
使用@Async实现异步任务
dyc87112 Sep 11, 2021
ee78526
@Async异步任务的线程池配置
dyc87112 Sep 14, 2021
0bfbf65
配置@Async异步任务的线程池
dyc87112 Sep 14, 2021
2a5e47d
@Async异步任务的线程池隔离
dyc87112 Sep 14, 2021
3dae3e6
Spring Security快速入门
dyc87112 Sep 14, 2021
8547205
1
dyc87112 Sep 15, 2021
7866b41
如何隔离@Async异步任务的线程池
dyc87112 Sep 15, 2021
9feeec7
为@Async异步任务线程池配置拒绝策略
dyc87112 Sep 22, 2021
ddcb8cc
为@Async异步任务线程池配置拒绝策略
dyc87112 Sep 22, 2021
832f554
为@Async异步任务线程池配置拒绝策略
dyc87112 Sep 22, 2021
f3e71f5
为@Async异步任务线程池配置拒绝策略
dyc87112 Sep 22, 2021
0b83b96
目录更新
dyc87112 Sep 22, 2021
28a71aa
移除2.1.x目录
dyc87112 Sep 23, 2021
bc2766b
Spring Boot 2.x基础教程:使用PostgreSQL
dyc87112 Oct 8, 2021
68f2ab0
更新目录
dyc87112 Oct 12, 2021
34c2eb9
更新目录
dyc87112 Oct 29, 2021
8f6234f
更新目录
dyc87112 Nov 9, 2021
e31efa0
更新目录
dyc87112 Dec 14, 2021
5d82536
默认日志管理与Logback配置详解
dyc87112 Dec 28, 2021
0dd9c71
使用log4j2记录日志
dyc87112 Dec 29, 2021
fc1f39b
使用log4j2记录日志
dyc87112 Dec 30, 2021
6f1bc8f
配置元数据的应用
dyc87112 Feb 9, 2022
07fd7ad
目录更新
dyc87112 Feb 9, 2022
fdd6b61
2.x版本教程
dyc87112 Feb 9, 2022
8d265aa
1.x版本教程(已完结)
dyc87112 Feb 9, 2022
fbf7926
使用tinylog记录日志
dyc87112 Feb 11, 2022
4212d16
使用tinylog记录日志
dyc87112 Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.class
.classpath
.project
build
bin
.bak
.settings
Thumbs.db
.DS_Store
._.DS_Store
logs
target
*.iml
.idea
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions 1.x/Chapter2-1-2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.didispace</groupId>
<artifactId>Chapter2-1-2</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Chapter2-1-2</name>
<description>Spring Boot 2.0 features : Application Events and Listeners</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

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

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

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
31 changes: 31 additions & 0 deletions 1.x/Chapter2-1-2/src/main/java/com/didispace/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@Slf4j
@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
public DataLoader dataLoader() {
return new DataLoader();
}

@Slf4j
static class DataLoader implements CommandLineRunner {

@Override
public void run(String... strings) throws Exception {
log.info("Loading data...");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationEnvironmentPreparedEventListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {

@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
log.info("......ApplicationEnvironmentPreparedEvent......");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {

@Override
public void onApplicationEvent(ApplicationFailedEvent event) {
log.info("......ApplicationFailedEvent......");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationPreparedEventListener implements ApplicationListener<ApplicationPreparedEvent> {

@Override
public void onApplicationEvent(ApplicationPreparedEvent event) {
log.info("......ApplicationPreparedEvent......");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {

@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
log.info("......ApplicationReadyEvent......");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationStartedEventListener implements ApplicationListener<ApplicationStartedEvent> {

@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
log.info("......ApplicationStartedEvent......");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.didispace;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;

@Slf4j
public class ApplicationStartingEventListener implements ApplicationListener<ApplicationStartingEvent> {

@Override
public void onApplicationEvent(ApplicationStartingEvent event) {
log.info("......ApplicationStartingEvent......");
}

}
6 changes: 6 additions & 0 deletions 1.x/Chapter2-1-2/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
org.springframework.context.ApplicationListener=com.didispace.ApplicationEnvironmentPreparedEventListener,\
com.didispace.ApplicationFailedEventListener,\
com.didispace.ApplicationPreparedEventListener,\
com.didispace.ApplicationReadyEventListener,\
com.didispace.ApplicationStartedEventListener,\
com.didispace.ApplicationStartingEventListener
49 changes: 49 additions & 0 deletions 1.x/Chapter2-2-1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.didispace</groupId>
<artifactId>Chapter2-2-1</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Chapter2-2-1</name>
<description>Spring Boot 2 : Relaxed Binding</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

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

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
44 changes: 44 additions & 0 deletions 1.x/Chapter2-2-1/src/main/java/com/didispace/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.didispace;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.ApplicationContext;

import java.util.List;

/**
*
* @author 程序猿DD
* @version 1.0.0
* @blog http://blog.didispace.com
*
*/
@SpringBootApplication
public class Application {

public static void main(String[] args) {
ApplicationContext context = SpringApplication.run(Application.class, args);

Binder binder = Binder.get(context.getEnvironment());

// 绑定简单配置
FooProperties foo = binder.bind("com.didispace", Bindable.of(FooProperties.class)).get();
System.out.println(foo.getFoo());

// 绑定List配置
List<String> post = binder.bind("com.didispace.post", Bindable.listOf(String.class)).get();
System.out.println(post);

List<PostInfo> posts = binder.bind("com.didispace.posts", Bindable.listOf(PostInfo.class)).get();
System.out.println(posts);

// 读取配置
System.out.println(context.getEnvironment().containsProperty("com.didispace.database-platform"));
System.out.println(context.getEnvironment().containsProperty("com.didispace.databasePlatform"));

}

}
14 changes: 14 additions & 0 deletions 1.x/Chapter2-2-1/src/main/java/com/didispace/FooProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.didispace;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@ConfigurationProperties(prefix = "com.didispace")
public class FooProperties {

private String foo;

private String databasePlatform;

}
13 changes: 13 additions & 0 deletions 1.x/Chapter2-2-1/src/main/java/com/didispace/PostInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.didispace;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@ConfigurationProperties
public class PostInfo {

private String title;
private String content;

}
10 changes: 10 additions & 0 deletions 1.x/Chapter2-2-1/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
com.didispace.foo=bar
com.didispace.database-platform=sql

com.didispace.post[0]=Why Spring Boot
com.didispace.post[1]=Why Spring Cloud

com.didispace.posts[0].title=Why Spring Boot
com.didispace.posts[0].content=It is perfect!
com.didispace.posts[1].title=Why Spring Cloud
com.didispace.posts[1].content=It is perfect too!
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public String postUser(@RequestBody User user) {
}

@ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public User getUser(@PathVariable Long id) {
return users.get(id);
}

@ApiOperation(value="更新用户详细信息", notes="根据url的id来指定更新对象,并根据传过来的user信息来更新用户详细信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"),
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path"),
@ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
})
@RequestMapping(value="/{id}", method=RequestMethod.PUT)
Expand All @@ -57,7 +57,7 @@ public String putUser(@PathVariable Long id, @RequestBody User user) {
}

@ApiOperation(value="删除用户", notes="根据url的id来指定删除对象")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
public String deleteUser(@PathVariable Long id) {
users.remove(id);
Expand Down
File renamed without changes.
File renamed without changes.
Loading