振伟普拉斯的博客

写写代码,做做架构


  • 首页

  • 归档

  • 标签

  • 摄影

  • 站点地图

  • 关于

  • 搜索

使用 spring-boot-dependencies 方便管理项目依赖

发表于 2021-01-14

当我们使用spring或spring-boot开发项目时,需要引入很多依赖,包括spring本身的组件、各种spring-boot-starter、以及其它第三方依赖(如:slf4j、redis)。

依赖多了,版本的选择是个问题,就怕哪个版本选择的不对导致出现一些意想不到的BUG。

比如下面这个例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
</dependencies>

slf4j的1.7.26版本、postgresql的42.2.14版本和spring的5.2.10.RELEASE版本会不会有冲突呢???

阅读全文 »

PostgreSQL 数据库的 jsonb 数组操作

发表于 2020-09-17

表结构

1
2
3
4
5
6
7
8
9
CREATE TABLE public.t_student_score_info
(
stu_id character varying(10) NOT NULL, -- 学号
score_info jsonb, -- 各科成绩
CONSTRAINT t_student_score_info_pkey PRIMARY KEY (stu_id)
);
COMMENT ON TABLE public.t_student_score_info IS '学生成绩表';
COMMENT ON COLUMN public.t_student_score_info.stu_id IS '学号';
COMMENT ON COLUMN public.t_student_score_info.score_info IS '各科成绩';
阅读全文 »

北环天桥上的慢门拍摄:车流轨迹

发表于 2020-08-24

20200824215610.jpg

20200824215554.jpg

SpringBoot 解决乱码问题:通过 spring.http.encoding.charset 指定返回 UTF-8 编码

发表于 2020-08-15

在使用 SpringBoot 开发后端系统时,为了能让返回的内容在不同浏览器(比如有些人使用英文版的 chrome)不同终端下都不会出现乱码问题,我们一般需要强制指定返回的编码类型为 UTF-8。

配置如下:

1
2
3
4
# application.properties
spring.http.encoding.force=true
spring.http.encoding.enabled=true
spring.http.encoding.charset=UTF-8
阅读全文 »

maven 打包跳过执行单元测试

发表于 2020-07-03

标准的 maven 项目,如果代码的 test 目录下有单元测试代码,在 package 打包时是会默认执行其测试用例的。如:

1600741477924

1600741682961

指定跳过执行测试用例的方式有多种:

阅读全文 »

【PostgreSQL 数据库】MyBatis Insert 获取插入行的主键

发表于 2020-07-02

MyBatis的insert方法返回的是受影响的记录行数。如果需要在insert时获取表字段自动生成的主键值可以在insert标签中增加设置两个属性:

  • useGeneratedKeys=”true”

  • keyProperty=”主键需要填充到实体的属性名”

keyProperty不是必填的,MyBatis会默认添加到实体对应的主键属性上。

阅读全文 »
12…35
振伟普拉斯

振伟普拉斯

209 日志
78 标签
RSS
Creative Commons
友情链接
  • 美团技术团队
  • 阿里中间件团队博客
  • 阮一峰的网络日志
粤ICP备18019803号 © 2017 – 2021 振伟普拉斯
|