Nevermind

Tonight I'm a rock'n roll star

记录使用 Mybatis 过程中的一些问题

ActiveRecord

现在只要继承 Model 类,就可以获得 CRUD 的能力。

必须确保项目中已经有对应实体的 BaseMapper

阅读全文 »

Api 接口返回值需要统一分装在

1
2
3
4
5
{
"code": 0,
"msg": "",
"data": <DATA>
}

中(需要吗?),通过 spring boot 的 ResponseBodyAdvice 实现:

阅读全文 »

Spring Boot (2.5.14) 默认使用的是 Jackson 来做序列化操作,在使用 redis stream 的过程中,暴露出了一些问题,遂做整理。

StringRedisTemplateRedisTemplate

spring-boot-starter-data-redis 默认注入了两个 bean:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package org.springframework.boot.autoconfigure.data.redis;

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
@Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class })
public class RedisAutoConfiguration {

@Bean
@ConditionalOnMissingBean(name = "redisTemplate")
@ConditionalOnSingleCandidate(RedisConnectionFactory.class)
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
return template;
}

@Bean
@ConditionalOnMissingBean
@ConditionalOnSingleCandidate(RedisConnectionFactory.class)
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
StringRedisTemplate template = new StringRedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
return template;
}

}
阅读全文 »

Spring Boot 中,线程都是从线程池中获取的,而这个线程用完后,不会销毁,而是放回线程池中。
因此如果使用 ThreadLocal,需要及时的 remove

stackoverflow

0%