Skip to content

Commit 6ab04ab

Browse files
authored
Merge branch 'master' into master
2 parents 1d35bb5 + 3504780 commit 6ab04ab

File tree

16 files changed

+149
-92
lines changed

16 files changed

+149
-92
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Sync
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Sync to Gitee
12+
uses: wearerequired/git-mirror-action@v1
13+
env:
14+
# 注意在 Settings->Secrets 配置 GITEE_SSH_PRIVATE_KEY
15+
SSH_PRIVATE_KEY: ${{ secrets.GITEE_SSH_PRIVATE_KEY }}
16+
with:
17+
# 注意替换为你的 GitHub 源仓库地址
18+
source-repo: "[email protected]:Snailclimb/springboot-guide.git"
19+
# 注意替换为你的 Gitee 目标仓库地址
20+
destination-repo: "[email protected]:SnailClimb/springboot-guide.git"

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[推荐一下:阿里云高性能服务器,1核1g最低89,不限性能。](https://www.aliyun.com/minisite/goods?userCode=hf47liqn)
2-
31
<p align="center">
42
<a href="https://github.com/Snailclimb/springboot-guide" target="_blank">
53
<img src="https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-7/spring-boot-guide.png" width=""/>
@@ -45,7 +43,6 @@
4543
3. **[如何在 Spring/Spring Boot 中做参数校验?你需要了解的都在这里!](./docs/advanced/spring-bean-validation.md)**
4644
4. [5分钟搞懂如何在Spring Boot中Schedule Tasks](./docs/advanced/SpringBoot-ScheduleTasks.md)
4745
5. **[新手也能看懂的 Spring Boot 异步编程指南](./docs/advanced/springboot-async.md)**
48-
6. **[Spring Boot 整合 阿里云OSS 存储服务,快来免费搭建一个自己的图床](https://github.com/Snailclimb/springboot-aliyun-oss)**
4946
7. **[Kafka 入门+SpringBoot整合Kafka系列](https://github.com/Snailclimb/springboot-kafka)**
5047
8. [超详细,新手都能看懂 !使用Spring Boot+Dubbo 搭建一个分布式服务](./docs/advanced/springboot-dubbo.md)
5148
9. [从零入门 !Spring Security With JWT(含权限验证)](https://github.com/Snailclimb/spring-security-jwt-guide)
@@ -69,8 +66,6 @@
6966

7067
如果大家想要实时关注我更新的文章以及分享的干货的话,可以关注我的公众号。
7168

72-
**《Java面试突击》:** 由本文档衍生的专为面试而生的《Java面试突击》V2.0 PDF 版本[公众号](#公众号)后台回复 **"Java面试突击"** 即可免费领取!
73-
7469
**Java工程师必备学习资源:** 一些Java工程师常用学习资源公众号后台回复关键字 **“1”** 即可免费无套路获取。
7570

7671
![我的公众号](https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-6/167598cd2e17b8ec.png)

docs/advanced/springboot-handle-exception-plus.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
在上一篇文章中我介绍了:
1+
2+
3+
> 这篇文章鸽了很久,我在这篇文章 [《用好Java中的枚举,真的没有那么简单!》](https://mp.weixin.qq.com/s?__biz=Mzg2OTA0Njk0OA==&mid=2247486111&idx=2&sn=8299a42edc4733bdf012ebfe9ebf3fbb&chksm=cea24554f9d5cc42eac0e0ecd851c201831f3b149e64fe11f94b548031f10ff2dac1ea9743d3&token=1729829670&lang=zh_CN#rd) 中就提到要分享。还是昨天一个读者提醒我之后,我才发现自己没有将这篇文章发到公众号。说到这里,我发现自己一个很大的问题,就是有时候在文章里面说要更新什么,结果后面就忘记了,很多时候不是自己没写,就因为各种事情混杂导致忘记发了。以后要尽量改正这个问题!
4+
5+
在上一篇文章[《SpringBoot 处理异常的几种常见姿势》](https://mp.weixin.qq.com/s?__biz=Mzg2OTA0Njk0OA==&mid=2247485568&idx=2&sn=c5ba880fd0c5d82e39531fa42cb036ac&chksm=cea2474bf9d5ce5dcbc6a5f6580198fdce4bc92ef577579183a729cb5d1430e4994720d59b34&token=1729829670&lang=zh_CN#rd)中我介绍了:
26

37
1. 使用 `@ControllerAdvice``@ExceptionHandler` 处理全局异常
48
2. `@ExceptionHandler` 处理 Controller 级别的异常

docs/basis/springboot-jpa-lianbiao.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# JPA 连表查询和分页
22

3-
对于连表查询,在 JPA 中还是非常常见的,由于 JPA 可以在 respository 层自定义 SQL 语句,所以通过自定义 SQL 语句的方式实现连表还是挺简单。这篇文章是在上一篇[入门 JPA](./springboot-jpa)的文章的基础上写的,不了解 JPA 的可以先看上一篇文章。
3+
对于连表查询,在 JPA 中还是非常常见的,由于 JPA 可以在 respository 层自定义 SQL 语句,所以通过自定义 SQL 语句的方式实现连表还是挺简单。这篇文章是在上一篇[入门 JPA](./springboot-jpa.md)的文章的基础上写的,不了解 JPA 的可以先看上一篇文章。
44

5-
[上一节](./springboot-jpa)的基础上我们新建了两个实体类,如下:
5+
[上一节](./springboot-jpa.md)的基础上我们新建了两个实体类,如下:
66

77
## 相关实体类创建
88

docs/basis/springboot-jpa.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ JPA 这部分内容上手很容易,但是涉及到的东西还是挺多的,
3838

3939
## 2.配置数据库连接信息和JPA配置
4040

41+
由于使用的是 h2 内存数据库,所以你直接运行项目数据库就会自动创建好。
42+
4143
下面的配置中需要单独说一下 `spring.jpa.hibernate.ddl-auto=create`这个配置选项。
4244

4345
这个属性常用的选项有四种:
@@ -50,15 +52,22 @@ JPA 这部分内容上手很容易,但是涉及到的东西还是挺多的,
5052
但是,**一定要不要在生产环境使用 ddl 自动生成表结构,一般推荐手写 SQL 语句配合 Flyway 来做这些事情。**
5153

5254
```properties
53-
spring.datasource.url=jdbc:mysql://localhost:3306/springboot_jpa?useSSL=false&serverTimezone=CTT
55+
# 数据库url地址
56+
spring.datasource.url=jdbc:h2:mem:jpa-demo
5457
spring.datasource.username=root
5558
spring.datasource.password=123456
59+
spring.datasource.platform=h2
60+
spring.datasource.driverClassName =org.h2.Driver
61+
62+
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
5663
# 打印出 sql 语句
5764
spring.jpa.show-sql=true
58-
spring.jpa.hibernate.ddl-auto=create
65+
spring.jpa.hibernate.ddl-auto=update
5966
spring.jpa.open-in-view=false
60-
# 创建的表的 ENGINE 为 InnoDB
61-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL55Dialect
67+
server.port=8080
68+
#H2控制台
69+
spring.h2.console.enabled=true
70+
6271
```
6372

6473
## 3.实体类

source-code/basis/jpa-demo/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<artifactId>mysql-connector-java</artifactId>
3333
<scope>runtime</scope>
3434
</dependency>
35+
<dependency>
36+
<groupId>com.h2database</groupId>
37+
<artifactId>h2</artifactId>
38+
<scope>runtime</scope>
39+
</dependency>
3540
<dependency>
3641
<groupId>org.projectlombok</groupId>
3742
<artifactId>lombok</artifactId>
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
spring.datasource.url=jdbc:mysql://localhost:3306/springboot_jpa?useSSL=false&serverTimezone=CTT
1+
# 数据库url地址
2+
spring.datasource.url=jdbc:h2:mem:jpa-demo
23
spring.datasource.username=root
34
spring.datasource.password=123456
5+
spring.datasource.platform=h2
6+
spring.datasource.driverClassName =org.h2.Driver
7+
8+
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
49
# 打印出 sql 语句
510
spring.jpa.show-sql=true
611
#常用的有四种:
712
# 1.create:每次重新启动项目都会重新创新表结构,会导致数据丢失
813
# 2.create-drop:每次启动项目创建表结构,关闭项目删除表结构
914
# 3.update:每次启动项目会更新表结构
1015
# 4. validate:验证表结构,不对数据库进行任何更改
11-
spring.jpa.hibernate.ddl-auto=create
16+
spring.jpa.hibernate.ddl-auto=update
1217
spring.jpa.open-in-view=false
13-
# 创建的表的 ENGINE 为 InnoDB
14-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL55Dialect
18+
server.port=8080
19+
#H2控制台
20+
spring.h2.console.enabled=true

source-code/basis/springboot-handle-exception-improved/.idea/modules/webApp.main.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source-code/basis/springboot-handle-exception-improved/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.1.9.RELEASE'
2+
id 'org.springframework.boot' version '2.1.8.RELEASE'
33
id 'java'
44
}
55

source-code/start/hello-world/src/main/java/com/example/helloworld/controller/BookController.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)