随笔分类 -  Java

摘要:引言 在单机环境中的并发编程中,需要用锁来保证数据的安全性。我们经常会用到synchronized,那么JVM中是如何实现synchronized的呢,在这篇文章中,我会从锁分类和锁膨胀(锁升级)的角度,会来探析一二。 为什么要有锁对象 Object lockObj = new Object(); 阅读全文
posted @ 2021-12-14 16:05 划破黑夜 阅读(175) 评论(0) 推荐(0)
摘要:com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.travelsky.dto.av.rs.Seg` (although at least one Creator 阅读全文
posted @ 2021-08-18 10:50 划破黑夜 阅读(1017) 评论(0) 推荐(0)
摘要:在SpringCloud中通常使用OpenFeign来封装微服务接口,有如下两种方式: 一、RequestLine注解 1.准备config @Configuration public class FeginConfig { @Bean public Contract feignConfigurat 阅读全文
posted @ 2021-03-03 23:51 划破黑夜 阅读(4651) 评论(0) 推荐(0)
摘要:配置项比较多时,可使用ConfigurationProperties代替Value,使用的方法如下。 1.创建ConfigBean @ConfigurationProperties(prefix = ConfigBean.PREFIX) @Data public class ConfigBean { 阅读全文
posted @ 2021-03-03 00:05 划破黑夜 阅读(312) 评论(0) 推荐(0)
摘要:Version 描述:乐观锁注解、标记 @Verison 在字段上 MybatisPlus有一个乐观锁注解,在使用的时候遇到一些问题。 乐观锁的字段在基类中,模型如下: @Data public class TblBase { @TableId(type = IdType.ASSIGN_ID) pr 阅读全文
posted @ 2021-02-20 10:32 划破黑夜 阅读(8249) 评论(0) 推荐(0)
摘要:为什么要使用并行库 在java中,我们通常使用并行库,达到对多核处理器的最大利用,提高程序执行效率。在java8中,我们可以使用parallelStream来做一些并行处理。 public static void main(String[] args) { testParalle(); } priv 阅读全文
posted @ 2021-02-03 16:12 划破黑夜 阅读(3585) 评论(0) 推荐(0)
摘要:一、spring-boot-starter-parent是什么? spring-boot-starter-parent是一个特殊的starter,其内置了许多springboot默认的maven依赖。使用spring-boot-starter-parent后,可以省去version标签,方便维护统一 阅读全文
posted @ 2020-12-16 15:42 划破黑夜 阅读(1386) 评论(0) 推荐(1)
摘要:在入口工程中的POM文件中添加如下配置: <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configu 阅读全文
posted @ 2020-12-15 17:53 划破黑夜 阅读(238) 评论(0) 推荐(0)
摘要:我有一个http接口如下,Hystrix策略设置为线程隔离,超时时间为10秒 @PostMapping("addBatch") @HystrixCommand(fallbackMethod = "addBatchFallBack", commandProperties = { @HystrixPro 阅读全文
posted @ 2020-04-07 23:03 划破黑夜 阅读(3817) 评论(0) 推荐(0)