Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

Netkiller Spring 手札

Springboot 4.0 Cookbook(2026版)

Mr. Neo Chan, 陈景峰(BG7NYT)



中国广东省深圳市望海路半岛城邦三期
518067
+86 13113668890


$Id: book.xml 606 2013-05-29 09:52:58Z netkiller $

电子书最近一次更新于 2026-07-14 16:50:39

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

http://www.netkiller.cn
http://netkiller.github.io
http://netkiller.sourceforge.net
微信公众号: netkiller
微信:13113668890 请注明“读者”
QQ:13721218 请注明“读者”
QQ群:128659835 请注明“读者”
知乎专栏

2017-11


致读者

Netkiller 系列手札 已经被 Github 收录,并备份保存在北极地下250米深的代码库中,备份会保留1000年。

Preserving open source software for future generations

The world is powered by open source software. It is a hidden cornerstone of modern civilization, and the shared heritage of all humanity.

The GitHub Arctic Code Vault is a data repository preserved in the Arctic World Archive (AWA), a very-long-term archival facility 250 meters deep in the permafrost of an Arctic mountain.

We are collaborating with the Bodleian Library in Oxford, the Bibliotheca Alexandrina in Egypt, and Stanford Libraries in California to store copies of 17,000 of GitHub’s most popular and most-depended-upon projects—open source’s “greatest hits”—in their archives, in museum-quality cases, to preserve them for future generations.

https://archiveprogram.github.com/arctic-vault/

目录

1. 自述
1.1. 写给读者
1.2. 作者简介
1.3. 如何获得文档
1.4. 打赏(Donations)
1.5. 联系方式
1. Spring Boot
1.1. Spring Boot Quick start
1.1.1. Springboot with Maven
1.2. Spring 开发环境
1.3. SpringApplication
1.3.1. 运行 Spring boot 项目
1.3.2. @SpringBootApplication
1.4. 如何优雅停止 Springboot 运行
1.5. Springboot with Properties 配置文件
1.6. Spring boot with Logging
1.7. Springboot with Undertow / Jetty / http2
1.7.1. Spring boot with Undertow
1.7.2. Spring boot with HTTP2 SSL
1.8. Spring boot with MongoDB
1.9. Spring boot with MySQL
1.10. Spring boot with Oracle
1.11. Spring boot with PostgreSQL
1.12. Spring boot with Elasticsearch
1.13. Spring boot with Elasticsearch TransportClient
1.14. Spring boot with Apache Hive
1.15. Spring boot with Phoenix
1.16. Spring boot with Datasource
1.16.1. Master / Slave 主从数据库数据源配置
1.17. 连接池配置
1.17.1. druid
1.18. Spring boot with Redis
1.18.1. Spring boot with Redis
1.18.2. Redis Pub/Sub
1.18.3. Sprint boot with Redisson
1.19. Spring boot with Queue
1.19.1. Spring boot with RabbitMQ(AMQP)
1.19.2. Spring boot with Apache Kafka
1.20. Spring boot with Scheduling
1.20.1. 启用计划任务
1.20.2. @Scheduled 详解
1.20.3. cron 表达式
1.21. Spring boot with Swagger
1.21.1. Spring boot with Springdoc
1.21.2. Spring boot with knife4j
1.21.3. springfox
1.22. Spring boot with lombok
1.23. Spring boot with Container
1.23.1. Spring boot with Docker
1.23.2. Spring boot with Docker stack
1.23.3. Spring boot with Kubernetes
1.24. Spring boot with command line
1.25. Spring Boot Actuator
1.25.1. 与 Spring Boot Actuator 有关的配置
1.25.2. 健康状态
1.25.3. info 配置信息
1.26. SpringBootTest
1.27. Spring boot with Aop
1.28. Spring boot with starter
1.28.1. 实现 starter
1.28.2. 引用 starter
1.29. Spring boot with Monitor
1.29.1. SpringBoot Admin
1.29.2. Spring boot with Grafana
1.29.3. Spring Boot with Prometheus
1.30. Spring boot with Git version
1.31. Spring boot with Session share
1.31.1. Redis
1.32. Spring boot with Caching
1.33. Spring boot with Email
1.33.1. spring-boot-starter-mail
1.33.2. 用法详解
1.34. Spring boot with Hessian
1.35. Spring boot with Async
1.35.1. 带有返回值的异步任务
1.35.2. 默认简单线程池 SimpleAsyncTaskExecutor
1.35.3. ThreadPoolTaskExecutor 自定义线程池
1.35.4. 自定义线程池 ThreadPoolExecutor
1.36. Springboot with Ethereum (web3j)
1.37. Java Record 新特性
1.38. Spring boot with Retryable
1.38.1. @EnableResilientMethods
1.38.2. spring-retry
1.39. Springboot 接入阿里云
1.40. Spring Boot 4 + OpenTelemetry
1.41. Springboot with Koog for Java
I. Spring Framework
2. Spring 框架
2.1. @Bean
2.1.1. @Scope 定义类型
2.1.2. InitializingBean
2.2. URL 拼装/解析
2.3. ServletUriComponentsBuilder
2.4. URL 路径相关
2.5. 声明式 HTTP 客户端 HttpExchange
2.5.1. 支持的注解类型
2.5.2. RestClient 例子
2.5.3. HTTP 头设置
3. Spring WebMVC
3.1. @EnableWebMvc
3.1.1. @PostConstruct
3.2. @Controller
3.2.1. @RequestMapping
3.2.2. @GetMapping
3.2.3. @PostMapping
3.2.4. @RequestBody
3.2.5. RequestMapping with Request Parameters - @RequestParam
3.2.6. @RequestHeader - 获取 HTTP Header 信息
3.2.7. RequestMapping with Path Variables - @PathVariable
3.2.8. @MatrixVariable注解,RFC3986定义URI的路径(Path)中可包含name-value片段
3.2.9. @ModelAttribute
3.2.10. @ResponseBody
3.2.11. @ResponseStatus 设置 HTTP 状态
3.2.12. @CrossOrigin
3.2.13. @CookieValue - 获取 Cookie 值
3.2.14. @SessionAttributes
3.2.15. ModelAndView
3.2.16. HttpServletResponse
3.2.17. HttpServletRequest
3.3. @RestController
3.3.1. 接口设计中 URL 参数,FORM 参数,JSON 怎么选择
3.3.2. 返回迭代器
3.3.3. 上传文件
3.3.4. 返回实体
3.3.5. JSON
3.3.6. 处理原始 RAW JSON 数据
3.3.7. 返回 JSON 对象 NULL 专为 "" 字符串
3.3.8. XML
3.3.9. 兼容传统 json 接口
3.3.10. 上传文件
3.3.11. 下载文件
3.3.12. Mime/MediaType
3.3.13. Spring boot with csv
3.3.14. Json 处理
3.3.15. synchronized
3.3.16. Spring boot with Emitter
3.3.17. forward 转发
3.4. Springboot 4.0
3.4.1. Api 版本控制
3.5. View
3.5.1. 配置静态文件目录
3.5.2. 添加静态文件目录
3.5.3. Using Spring’s form tag library
3.5.4. Thymeleaf
3.5.5. FreeMarker
3.5.6. i18n 国际化
3.6. Spring boot with Webpage
3.6.1. Maven
3.6.2. application.properties
3.6.3. Application
3.6.4. IndexController
3.6.5. src/main/webapp/WEB-INF/jsp/index.jsp
3.6.6. 集成模板引擎
3.7. Spring boot with Velocity template
3.7.1. Maven
3.7.2. Resource
3.7.3. Application
3.7.4. RestController
3.7.5. Test
3.8. Spring boot with Thymeleaf
3.8.1. Maven
3.8.2. application.properties
3.8.3. Controller
3.8.4. HTML5 Template
3.9. 校验器(Validator)
3.9.1. 依赖
3.9.2. 常规用法
3.9.3. 常用注解
3.9.4. 在 Service 中使用 Validator 检查数据
3.9.5. 自定义注解
3.10. Interceptor/Filter 拦截器/过滤
3.10.1. Session 拦截
3.10.2. Token 拦截
3.10.3. Authorization Bearer
3.10.4. 过滤器
3.10.5. 拦截器获取PathVariable变量
3.10.6. WebMvcConfigurer 拦截
3.10.7. Session 登录拦截器
3.11. String boot with RestTemplate
3.11.1. RestTemplate Example
3.11.2. GET 操作
3.11.3. POST 操作
3.11.4. PUT 操作
3.11.5. Delete 操作
3.11.6. 上传文件
3.11.7. HTTP Auth
3.11.8. PKCS12
3.11.9. Timeout 超时设置
3.12. RestClient
3.12.1. 创建 RestClient
3.12.2. Get 操作
3.12.3. Post Json
3.12.4. HTTP Authorization Basic
3.12.5. onStatus
3.12.6. Timeout 超时设置
3.12.7. 下载二进制流
3.12.8. 上传文件
3.12.9. Springboot 4.0 Version 版本号
5. Service
5.1. Application
5.2. 定义接口
5.3. 实现接口
5.4. 调用 Service
5.5. context.getBean 调用 Service
5.6. AopContext
5.7. Service 单例/多例模式
5.7.1. Service 是单例模式
5.7.2. Service 多例实现
5.8. 构造方法
6. Tomcat Spring 运行环境
6.1. Maven
6.2. Spring MVC configuration
6.3. Tomcat
6.4. 集成 Mybatis
6.4.1. pom.xml
6.4.2. properties
6.4.3. dataSource
6.4.4. SqlSessionFactory
6.4.5. Mapper 扫描
6.4.6. Mapper 单一class映射
6.4.7. Service
6.4.8. 测试实例
7. WebFlux framework
7.1. Getting Started
7.1.1. Maven
7.1.2. Application
7.1.3. RestController
7.1.4. 测试
7.2. WebFlux 与 SprintMVC 有什么不同?
7.2.1. 实验程序
7.2.2. 实验结果
7.3. WebFlux Router
7.3.1. Component 原件
7.3.2. 路由配置
7.4. RestController
7.4.1. Post 数据
7.4.2. Thymeleaf
7.4.3. Mono
7.4.4. Flux 返回多条数据
7.4.5. SSE
7.4.6. 末尾连接字符串
7.4.7. Flux scan
7.4.8. ConnectableFlux
7.4.9. 上传文件并保存
7.5. Newline Delimited JSON (NDJSON)
7.6. WebClient
7.6.1. 配置 WebClient
7.6.2. @Controller/@RestController 实例
7.6.3. Get 请求实例
7.6.4. URI 参数
7.6.5. 查询参数
7.6.6. Post 操作演示
7.6.7. Post 表单数据
7.6.8. 上传文件
7.6.9. 设置 HTTP 头
7.6.10. 同步阻塞等待返回结果
7.6.11. websocket
7.6.12. 获取 HTTP 链接状态
7.6.13. Http Base Authentication - 401 Unauthorized
7.6.14. SSE(Server-Sent Events)
7.6.15. 超时时间
7.6.16. share() 共享订阅数据
7.6.17. 打印调试日志
7.6.18. 解决 WebClient 截断 URI的问题
7.6.19. 异常处理
7.7. Webflux 安全
7.7.1. Token 拦截器
7.7.2. JWT
7.7.3. spring-boot-starter-security
7.8. R2DBC
7.8.1. MySQL
7.8.2. R2dbcEntityTemplate
7.8.3. MySQL Point 数据类型
7.9. Webflux Redis
7.9.1. Maven Redis 依赖
7.9.2. Redis 配置
7.9.3. Config
7.9.4. Service
7.9.5. RestController
7.10. Webflux Mongdb
7.10.1. Maven 依赖
7.10.2. Repository
7.10.3. Service
7.10.4. 控制器
7.11. 常见问题
7.11.1. The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, e.g. via @EnableWebMvc and @EnableWebFlux, in the same application.
7.11.2. @EnableWebFluxSecurity 与 @EnableReactiveMethodSecurity 不生效
7.11.3. webflux netty 不支持 Content-Type: application/x-www-form-urlencoded
II. Spring Data
8. EntityManager
9. Spring Data with JdbcTemplate
9.1. execute
9.2. queryForInt
9.3. queryForLong
9.4. queryForObject
9.4.1. 返回整形与字符型
9.4.2. 查询 Double 类型数据库
9.4.3. 返回日期
9.4.4. 返回结果集
9.4.5. 通过 "?" 向SQL传递参数
9.4.6. RowMapper 记录映射
9.5. queryForList
9.5.1. Iterator 用法
9.5.2. for 循环
9.5.3. forEach 用法
9.6. queryForMap
9.7. query
9.7.1. ResultSet
9.7.2. ResultSetExtractor
9.7.3. RowMapper
9.8. queryForRowSet
9.9. update
9.10. MapSqlParameterSource
9.11. 实例参考
9.11.1. 参数传递技巧
10. Spring Data with MySQL
10.1. 选择数据库表引擎
10.2. 声明实体
10.2.1. @Entity 声明实体
10.2.2. @Table 定义表名
10.2.3. @Id 定义主键
10.2.4. @Column 定义字段:
10.2.5. 非数据库字段
10.2.6. @Lob 注解属性将被持久化为 Blog 或 Clob 类型
10.2.7. @NotNull 不能为空声明
10.2.8. @Temporal 日期定义
10.2.9. 创建日期
10.2.10. @DateTimeFormat 处理日期时间格式
10.2.11. Enum 枚举数据类型
10.2.12. SET 数据结构
10.2.13. JSON 数据类型
10.2.14. 嵌入
10.2.15. @JsonIgnore
10.2.16. @EnableJpaAuditing 开启 JPA 审计功能
10.2.17. 注释 @Comment
10.2.18. @Pattern 数据匹配
10.2.19. 实体继承
10.2.20. 虚拟列
10.2.21. 语言区域
10.3. 映射集合属性
10.3.1. List 集合
10.3.2. 数组集合
10.3.3. Map 集合
10.3.4. Set 集合
10.3.5. 外键名称
10.3.6. 集合表子查询
10.4. 外键
10.4.1. @JoinColumn
10.4.2. @OneToOne
10.4.3. OneToMany 一对多
10.4.4. ManyToMany 多对多
10.4.5. 外键级联删除
10.4.6. 外键级联操作
10.4.7. @JoinTable
10.4.8. @OrderBy
10.4.9. @JsonIgnoreProperties
10.4.10. 允许外键为 NULL
10.4.11. 只要外键,不要数据结构
10.5. 索引
10.5.1. 普通索引
10.5.2. 组合索引
10.5.3. 唯一索引
10.6. Repository/CrudRepository/PagingAndSortingRepository/JpaRepository
10.6.1. JpaRepository
10.6.2. CrudRepository
10.6.3. PagingAndSortingRepository
10.6.4. findByXXX
10.6.5. count 操作
10.6.6. delete 删除操作
10.6.7. IsNull
10.6.8. In/NotIn
10.6.9. TRUE / FALSE
10.6.10. 比较数值大小
10.6.11. 判断日期和时间 Before / After
10.6.12. Between
10.6.13. Exists
10.6.14. OrderBy
10.6.15. GreaterThan
10.6.16. Sort 排序操作操作
10.6.17. Pageable 翻页操作
10.6.18. @DynamicInsert 与 @DynamicUpdate
10.6.19. 继承已存在的 Repository
10.6.20. Optional
10.6.21. stream 用法
10.7. TransactionTemplate
10.8. JPQL @Query
10.8.1. @Modifying 更新/删除
10.8.2. 参数传递
10.8.3. 原生 SQL 操作
10.8.4. @Query 与 Pageagble
10.8.5. 自定义返回字段
10.8.6. 返回指定字段
10.8.7. 返回指定的模型
10.8.8. 通过定义接口,返回指定字段
10.8.9. 修改返回数据
10.8.10. 事务 @Transactional
10.8.11. IN / NOT 子查询
10.9. FAQ 常见问题
10.9.1. Could not write JSON: failed to lazily initialize a collection of role
10.9.2. Query did not return a unique result: 2 results were returned
10.9.3. Executing an update/delete query
10.9.4. could not initialize proxy [cn.netkiller.domain.Device#16] - no Session
10.9.5. this is incompatible with sql_mode=only_full_group_by
10.9.6. A TupleBackedMap cannot be modified
11. Spring Data with Redis
11.1. 集成 Redis XML 方式
11.1.1. pom.xml
11.1.2. springframework-servlet.xml
11.1.3. Controller
11.1.4. index.jsp
11.1.5. 测试
11.2. 通过构造方法实例化 Redis
11.3. StringRedisTemplate 基本用法
11.3.1. 存储数据
11.3.2. 获取值并删除
11.3.3. 取出数据
11.4. RedisTemplate
11.4.1. 设置缓存时间
11.4.2. increment
11.4.3. 删除 key
11.4.4. 对象存储
11.4.5. 获取过期时间
11.4.6. 过期时间未执行
11.4.7. 判断 key 是否存在
11.5. ValueOperations
11.5.1. 字符串截取
11.5.2. 追加字符串
11.5.3. 设置键的字符串值并返回其旧值
11.5.4. 返回字符串长度
11.5.5. 如果key不存便缓存。
11.5.6. 缓存多个值 /获取多个值 multiSet / multiGet
11.5.7. setBit / getBit 二进制位操作
11.6. 列表操作
11.6.1. rightPush
11.6.2. rightPushAll
11.6.3. rightPushIfPresent
11.6.4. leftPush
11.6.5. leftPushAll
11.6.6. range
11.7. SetOperations 数据类型
11.7.1. 返回集合中的所有成员
11.7.2. 取出一个成员
11.7.3. 随机获取无序集合中的一个元素
11.7.4. 随机获取 n 个成员(存在重复数据)
11.7.5. 随机获取 n 个不重复成员
11.7.6. 在两个 SET 间移动数据
11.7.7. 成员删除
11.7.8. 返回集合数量
11.7.9. 判断元素是否在集合成员中
11.7.10. 对比两个集合求交集
11.7.11. 对比两个集合求交集,然后存储到新的 key 中
11.7.12. 合并两个集合,并去处重复数据
11.7.13. 合并两个集合去重复后保存到新的 key 中
11.7.14. 计算两个合集的差集
11.7.15. 计算两个合集的差集,然后保存到新的 key 中
11.7.16. 遍历 SET 集合
11.8. ZSetOperations 有序的 set 集合
11.9. HashOperations
11.9.1. put
11.9.2. putAll
11.9.3. 从键中的哈希获取给定hashKey的值
11.9.4. delete
11.9.5. 确定哈希hashKey是否存在
11.9.6. 从哈希中获取指定的多个 hashKey 的值
11.9.7. 只有hashKey不存在时才能添加值
11.9.8. 获取整个Hash
11.9.9. 获取所有key
11.9.10. 通过 hashKey 获取所有值
11.9.11. 值加法操作
11.9.12. 遍历 Hash 表
11.10. 存储 Json 对象
11.10.1. 集成 RedisTemplate 定义新类 JsonRedisTemplate
11.10.2. 配置 Redis
11.10.3. 测试
11.11. Spring Data Redis - Repository Examples
11.11.1. @EnableRedisRepositories 启动 Redis 仓库
11.11.2. 定义 Domain 类
11.11.3. Repository 接口
11.11.4. 测试代码
11.12. Redis Pub/Sub
11.12.1. MessageListener 方案
11.12.2. @RedisListener 注解方案
11.12.3. 线程池
11.13. CacheService
11.14. FAQ
11.14.1. Spring Data Redis
12. Spring Data with MongoDB
12.1. Example Spring Data MongoDB
12.1.1. pom.xml
12.1.2. springframework-servlet.xml
12.1.3. POJO
12.1.4. Controller
12.1.5. 查看测试结果
12.1.6. 条件查询
12.2. MongoDB 多数据源
12.2.1. Maven
12.2.2. Application 禁止自动配置 MongoDB
12.2.3. application.properties 新增配置项
12.2.4. MongoDB 配置类
12.2.5. 创建 Document 关系映射类
12.2.6. 测试控制器
12.2.7. 测试
12.3. @Document
12.3.1. 指定表名
12.3.2. @Id
12.3.3. @Version
12.3.4. @Field 定义字段名
12.3.5. @Indexed
12.3.6. @CompoundIndex 复合索引
12.3.7. @TextIndexed
12.3.8. @GeoSpatialIndex 地理位置索引
12.3.9. @Transient 丢弃数据,不存到 mongodb
12.3.10. @DBRef 做外外键引用
12.3.11. @DateTimeFormat
12.3.12. @NumberFormat
12.3.13. 在 @Document 中使用 Enum 类型
12.3.14. 在 @Document 中定义数据结构 List/Map
12.3.15. GeoJson 数据类型
12.4. MongoRepository
12.4.1. 扫描仓库接口
12.4.2. findAll()
12.4.3. deleteAll()
12.4.4. save()
12.4.5. count()
12.4.6. exists() 判断是否存在
12.4.7. existsById()
12.4.8. findByXXXX
12.4.9. findAll with OrderBy
12.4.10. findAll with Sort
12.4.11. FindAll with Pageable
12.4.12. StartingWith 和 EndingWith
12.4.13. Between
12.4.14. Before / After
12.4.15. @Query
12.5. mongoTemplate
12.5.1. Save 保存
12.5.2. Insert
12.5.3. updateFirst 修改符合条件第一条记录
12.5.4. updateMulti 修改符合条件的所有
12.5.5. 查找并保存
12.5.6. upsert - 修改符合条件时如果不存在则添加
12.5.7. 删除
12.5.8. 查找一条数据
12.5.9. 查找所有数据
12.5.10. Query
12.5.11. Criteria
12.5.12. Update
12.5.13. BasicUpdate
12.5.14. Sort
12.5.15. Query + PageRequest
12.5.16. newAggregation
12.5.17. 创建索引
12.5.18. 子对象操作
12.6. GeoJson 反序列化
12.7. FAQ
12.7.1. location object expected, location array not in correct format; nested exception is com.mongodb.MongoWriteException: location object expected, location array not in correct format
13. Spring Data with Elasticsearch
13.1. 内嵌 Elasticsearch
13.1.1. Maven
13.1.2. src/main/resources/application.properties
13.1.3. Domain Class
13.1.4. ElasticsearchRepository
13.1.5. SearchRestController
13.1.6. 测试
13.2. 集群模式
13.3. Document
13.4. Elasticsearch 删除操作
13.5. FAQ
13.5.1. java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
14. Spring boot with Data restful
14.1. Maven
15. Apache ShardingSphere
15.1. 微服务集群环境,雪花算法出现重复ID
15.1.1. 方案一、配置实现
15.1.2. 方案二、代码实现
III. Spring Security
16. Springboot 3 + Security 6
16.1. Spring Security with HTTP Auth
16.1.1. 默认配置
16.1.2. 设置用户名和密码
16.1.3. 禁用 Security
16.1.4. 设置角色
16.2. Springboot 3 Security + OncePerRequestFilter
16.2.1. OncePerRequestFilter
16.2.2. SecurityConfiguration
16.3. SecurityFilterChain
16.4. @PreAuthorize
16.4.1. hasRole
16.4.2. hasAnyRole
16.4.3. 从 HttpServletRequest 返回的 request 变量中判断角色
16.4.4. getAuthentication() 获得角色
16.4.5. UserDetailsService
16.5. httpBasic 配置
16.5.1. 禁止 HTTP Auth
16.6. 指定 URL 限制 IP 访问
16.7. Authorization Bearer
16.8. InvalidClaimException: The Token can't be used before
17. Spring Authorization Server
17.1. Oauth2 协议
17.1.1. token
17.1.2. grant_type
17.1.3. 授权码授权模式(Authorization Code Grant)
17.1.4. 密码模式(Resource Owner Password Credentials Grant)
17.1.5. 客户端凭证模式(Client Credentials Grant)
17.1.6. 刷新 TOKEN 方式
17.2. Maven 依赖
17.3. Spring cloud with Oauth2
17.3.1. authorization_code
17.3.2. Spring boot with Oauth2 - Password
17.3.3. Spring boot with Oauth2 jwt
17.3.4. Spring boot with Oauth2 jwt 非对称证书
17.3.5. Apple iOS 访问 Oauth2
17.3.6. Oauth2 客户端
17.3.7. Android Oauth2 + Jwt example
17.3.8. RestTemplate 使用 HttpClient
17.3.9. 自签名证书信任问题
17.3.10. Principal
17.3.11. SecurityContextHolder 对象
17.3.12. 资源服务器配置
17.3.13. Client
17.3.14. Oauth2 常见问题
18. Spring boot with Spring security(2.x)
18.1. Spring security 静态配置例子
18.1.1. Maven
18.1.2. Reource
18.1.3. Application
18.1.4. WebSecurityConfigurer
18.1.5. RestController
18.1.6. 测试
18.2. Spring + Security + MongoDB
18.2.1. Account
18.2.2. AccountRepository
18.2.3. WebSecurityConfiguration
18.3. Spring Boot with Web Security(2.x)
18.3.1. EnableWebSecurity
18.3.2. Web静态资源
18.3.3. 正则匹配
18.3.4. 登陆页面,失败页面,登陆中页面
18.3.5. CORS
18.3.6. X-Frame-Options 安全
18.4. 访问控制列表(Access Control List,ACL)
18.4.1. antMatchers
18.4.2. HTTP Auth
18.4.3. Rest
18.4.4. hasRole
18.4.5. hasAnyRole()
18.4.6. withUser
IV. Spring Cloud
19. Spring Cloud
19.1. Spring Cloud 相关的 application.properties 配置
19.1.1. 启用或禁用 bootstrap
19.1.2. bootstrap.properties 配置文件
20. Spring Cloud Config
20.1. Maven 项目 pom.xml 文件
20.2. Server
20.2.1. Maven config 模块
20.2.2. Application
20.2.3. application.properties
20.2.4. Git 仓库
20.2.5. 测试服务器
20.3. Client
20.3.1. Maven pom.xml
20.3.2. Application
20.3.3. bootstrap.properties
20.3.4. 测试 client
20.4. Config 高级配置
20.4.1. 仓库配置
20.4.2. Config server 用户认证
20.4.3. 加密敏感数据
20.4.4. Spring Cloud Config JDBC Backend
20.5. Old
20.5.1. Server (Camden.SR5)
20.5.2. Client (Camden.SR5)
21. Spring Cloud Consol
21.1. Spring Cloud Consul 配置
21.2. Maven 父项目
21.3. Consul 服务生产者
21.3.1. Maven
21.3.2. application.properties
21.3.3. SpringApplication
21.3.4. TestController
21.4. Consul 服务消费者
21.4.1. Maven
21.4.2. application.properties
21.4.3. SpringApplication
21.4.4. TestController
21.5. Openfeign
21.5.1. Maven
21.5.2. application.properties
21.5.3. SpringApplication
21.5.4. Feign 接口
21.5.5. TestController
22. Spring Cloud Netflix
22.1. Eureka Server
22.1.1. Maven
22.1.2. Application
22.1.3. application.properties
22.1.4. 检查注册服务器
22.2. Eureka Client
22.2.1. Maven
22.2.2. Application
22.2.3. RestController
22.2.4. application.properties
22.2.5. 测试
22.3. Feign client
22.3.1. Maven
22.3.2. Application
22.3.3. interface
22.3.4. application.properties
22.3.5. 测试
22.3.6. fallback
22.4. 为 Eureka Server 增加用户认证
22.4.1. Maven
22.4.2. application.properties
22.4.3. Eureka Client
22.4.4. Feign Client
22.5. Eureka 配置项
22.5.1. /eureka/apps
22.5.2. Eureka instance 配置项
22.5.3. Eureka client 配置项
22.5.4. Eureka Server配置项
22.6. ribbon
22.6.1.
22.6.2. LoadBalancerClient 实例
22.6.3. Ribbon 相关配置
22.7. 获取 EurekaClient 信息
22.8. Zuul
22.8.1. Maven
22.8.2. EnableZuulProxy
22.8.3. application.yml
22.8.4. 负载均衡配置
23. Openfeign
23.1. Openfeign 扫描包配置
23.2. 用户认证
23.3. 应用实例
23.4. 配置连接方式
23.4.1. httpclient
23.4.2. okhttp
23.5. 配置手册
24. Spring Cloud Gateway
24.1. Gateway 例子
24.1.1. Maven
24.1.2. SpringApplication
24.1.3. application.yml
24.1.4. RouteLocator 方式
24.2. 路由配置
24.2.1. 转发操作
24.2.2. URL 参数
25. Spring Cloud Sleuth
25.1. logback 安装
26. Spring Cloud with Kubernetes
26.1. Config
26.1.1. Maven 依赖
26.1.2. Spring Cloud 配置文件
26.1.3. 程序文件
26.1.4. Kubernetes 编排脚本
26.1.5. 测试
26.2. 注册发现
26.2.1. Maven 父项目
26.2.2. provider
26.2.3. consumer
26.2.4. 测试
26.2.5.
27. Spring Cloud Alibaba
27.1. 安装 Nacos
27.1.1. Docker 安装 Nacos
27.1.2. Kubernetes 安装 Nacos
27.1.3. IP限制,白名单
27.1.4. 防火墙配置
27.2. Kubernetes 部署微服务
27.2.1. pom.xml 中加入 docker 插件
27.2.2. 容器启动脚本
27.2.3. 构建 docker 镜像
27.2.4. 编排 kubernetes 容器
27.2.5. 启动指定 nacos
27.3. Nacos 配置中心/注册中心代码实例
27.3.1. Maven
27.3.2. SpringBootApplication
27.3.3. ConfigController
27.3.4. 配置文件
27.4. FAQ
27.4.1. 禁用 Nacos
27.4.2. 禁止注册
27.4.3. Failed to bind properties under 'server.tomcat.basedir' to java.io.File:
27.4.4. 不读取 bootstrap.yaml 文件
27.4.5. WARN [com.alibaba.nacos.client.naming:177] [,] - out of date data received, old-t: 1665711914993, new-t: 1665711902390
27.4.6. User limit of inotify instances reached or too many open files
27.4.7. 开启权限
27.4.8. ERROR Whitelabel
27.4.9.
28. FAQ
28.1. Cannot execute request on any known server
28.2. @EnableDiscoveryClient与@EnableEurekaClient 区别
28.3. Feign请求超时
28.4. 已停止的微服务节点注销慢或不注销
28.5. Feign 启动出错 PathVariable annotation was empty on param 0.
28.6. Feign 提示 Consider defining a bean of type 'common.feign.Cms' in your configuration.
28.7. Load balancer does not have available server for client
28.8. Eureka Client (Dalston.SR1)
28.8.1. Maven
28.8.2. Application
28.8.3. RestController
28.8.4. application.properties
28.8.5. 测试
28.9. Config Server(1.3.1.RELEASE)
28.9.1. Server
28.9.2. Client
28.10. feign.RetryableException: Read timed out executing
29. Spring Integration
29.1. Spring Redis Lock
29.1.1. Maven 依赖
29.1.2. 配置锁
29.1.3. 使用方法
29.1.4. Service 中使用方法
29.1.5. 在定时任务中使用
29.1.6. 在Controller中使用
29.1.7. 使用模板方法模式封装
29.1.8. 读取锁过期时间
29.2. MQTT Support
29.2.1. 入站消息通道适配器
29.2.2. 出站通道适配器
29.2.3. @MessagingGateway 定义消息网管接口
29.2.4. 手动 ACK 应答
29.2.5. Spring boot with Mqtt v5
1. 附录
1.1. Springboot example

表格清单

1. Netkiller 系列免费电子书

范例清单

1.1. Example Spring boot with Oracle
1.2. RedisTemplate
1.3. Spring boot with Apache kafka.
1.4. Spring boot with Apache kafka.
1.5. Test Spring Kafka
1.6. Spring boot with Email (pom.xml)
3.1. Spring boot with Velocity template (pom.xml)
6.1. MyBatis
10.1. JPA deleteBy 返回删除数量
10.2. JPA 更多用法
11.1. Spring Data Redis Example
12.1. Spring Data MongoDB - springframework-servlet.xml
28.1. Share feign interface.