SpringCloud Bus 刷新不了配置
不要使用@Value("${config.test}")
private String test;
改为使用@ConfigurationProperties(prefix = "config")
@Component
public class UserConfig{
private String
Windows 创建软链接
比如将chrome的缓存从系统盘重定向到其他盘mklink /D sourcePath targetPath
示例mklink /D "C:\Users\root\AppData\Local\Google\Chrome\User Data\Default" D:\soft\chrome\Defaul
JPA IN or NOT IN 查询时 只能传List
JPA IN 查询时 只能传List
map为空时调用keySet()传给jpa导致的bug
userService.deleteNotInId(userMap.keySet());
@Modifying
@Query(value = "DELETE FROM user WHERE id NOT IN (:iqs)", nativeQuery = true)
void deleteNotIn
jpa方法参数必须加上@Param
void deleteByKl(String kl);线上可能报错原因可能是编译时没有加-parameters这个参数, 编译后丢失了参数名称, 使得反射拿不到对应参数需要加上注解void deleteByKl(@Param("kl") String kl);同理public ResultVO de
Chrome翻译插件url指向国内站点
安装google翻译插件找到安装路径将translate.google.com全部替换成translate.google.cn将文件夹复制出来加载已解压的拓展程序
日志规范
日志中要打印参数错误示例 @GetMapping("/share_coupon")
public ActionResult shareCoupon(Long couponSn) {
//validate code
try {
retur
AOP拦截controller方法注入参数 代替@RequestBody
效果如下加上@Pass放弃aop拦截注入,使用spring mvc的参数注入核心方法package com.github.aop;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxm
hutool-http链式调用参数丢失
版本hutool-http-5.2.5如下代码,pathParams的参数会丢失 HttpRequest request =
cn.hutool.http.HttpUtil.createRequest(method, url).timeout(TIMEOUT)
.
Android App 自动转发短信
项目地址https://github.com/MQPearth/SMS-Auto-Forward
拒绝DNS污染,秒开Github
修改hosts文件https://github.com/521xueweihan/GitHub520
SpringBoot加载自定义yml文件
官方推荐使用yml,却不支持自定义的yml,匪夷所思。package com.xxx.xxx.xxx;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
i
EXPLAIN 命令
EXPLAIN
SELECT * FROM Test WHERE id = 200
其中:id — 选择标识符,id 越大优先级越高,越先被执行;select_type — 表示查询的类型;table — 输出结果集的表;partitions — 匹配的分区;type — 表示表的连接类型;poss
@Transactional可在抽象类上定义,且能生效
定义一个抽象类
import com.shopping.base.repository.sync.ipos.coupon.IposCzklbRepository;
import org.springframework.beans.factory.annotation.Autowired;
impor
多数据源 单库操作事务不回滚
项目配置了多数据源,之前操作主数据源,直接加上@Transactional(rollbackFor = Exception.class),没有任何问题最近操作其他数据源并做测试的时候,发现int i = 1 / 0并不会回滚,各种排查,从数据库引擎到注解@Transactional使用规范和异常处理
设计模式:模板方法模式
抽象类中定义方法,设置程序“骨架”
public abstract class Template {
public void templ() {
System.out.println("开始");
code();
System.out.println("结束");
}
p
如何将一个长URL转换为一个短URL?
https://blog.csdn.net/xlgen157387/article/details/80026452
SpringBoot线程池+多线程
启动类上加注解
@SpringBootApplication
@EnableAsync
public class SpringApplication {
public static void main(String[] args) {
SpringApplication.r