Chuenhung的个人网站

chuenhung.github.io

MySQL数据库生成自动增长序号

变量需要每次初始化为0,否则会自增
参考代码:

1
2
SELECT (@i:=@i+1) AS orderNo , p.proposition_code AS propositionCode , p.proposition_name AS propositionName
FROM t_proposition_collect p,(SELECT @i := 0) AS i

参考链接

阅读全文 »

@PostConstruct注解

示例代码:

1
2
3
4
5
6
7
8
9
10
@Configuration
@ComponentScan({"com.aspirecn.external.reward"})
@MapperScan("com.aspirecn.external.reward.mapper")
@Slf4j
public class ExternalRewardConfiguration {
@PostConstruct
private void init() {
log.info("自动装配ExternalRewardConfiguration");
}
}

参考链接

阅读全文 »

Hexo博客 Next主题图片防盗链问题

问题场景:打开博客,所有引用外部链接的图片均无法正常加载,但是所有图片复制链接在浏览器请求是可以加载的。
问题原因:目标网站图片设置了防盗链。
解决方案:在 \themes\next\layout_partials\head.swig文件中加一行代码即可。
在这里插入图片描述
参考链接参考链接

Springboot Druid数据库密码加密配置步骤

方式一:

  • 找到druid包的位置,CMD命令行执行下面的命令
1
java -cp druid-1.2.6.jar com.alibaba.druid.filter.config.ConfigTools 数据库密码 > pwd.txt
  • 把项目中的解密公钥和密文改为pwd.txt中的publicKey、password
阅读全文 »

Spring缓存相关注解

@Cacheable注解

对于一个使用@Cacheable标注的方法,Spring会在其被调用后将其返回值缓存起来,以保证下次利用同样的参数来执行该方法时可以直接从缓存中获取结果,而不需要再次执行该方法。
cacheNames和value这两个属性任意使用一个都可以,且必须指定,否则会报错。它们的作用可以理解为key的前缀。

1、key和value都指定

1
@Cacheable(key = "'testKey'", value = "testValue")

生成的Redis键格式为:testValue::testKey

在这里插入图片描述

2、key和cacheNames都指定

1
@Cacheable(cacheNames = {"testNames","testNamesTwo"}, key = "'testKey'")

会生成多个Redis键,格式为:testNames::testKey
在这里插入图片描述

阅读全文 »
0%