- 博客(38)
- 收藏
- 关注
原创 订单防重(幂等性)
幂等性需要唯一的业务订单号来保证情况一:不考虑并发+单表 1.先query后——>再参数校验是否支付过——>在执行支付; 缺点:高并发下性能低,不具备原子性,防重率低; 情况二:并发+单表 2.乐观锁+ABA 缺点:ABA问题 3.mysql唯一索引 4.利用redis的原子性实现分布式锁 将orderID作为key,setnx——del, 5.或...
2019-02-28 16:20:15
5398
原创 ReentrantLock中CAS解析(1)
在此之前已有大佬分析过其中lock–unlock实现的机制https://www.cnblogs.com/java-zhao/p/5131544.html在这里补充下JNI层面的实现原理在lock()第二次尝试获取锁时:调用下面的方法 final boolean nonfairTryAcquire(int acquires) { final Thread curre...
2019-02-26 11:29:29
739
原创 "Fri Feb 22 20:22:00 CST 2019"字符串型转date
第三方接口回调我们,有一个时间的参数,字符串类型Java 日期格式是“Fri Feb 22 20:22:00 CST 2019”字符串类型,转date类型: String value="Fri Feb 22 20:22:00 CST 2019"; SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:s...
2019-02-22 20:37:49
8762
原创 Shell脚本学习——实现重启tomcat
1. 一般手动操作有几个步骤:ps -ef |grep xxxkill -9 xxx(PID)cd xxx/binsh startup.shtail -100f …/log/catainla.out2. 现在用shell脚本实现#tomcat_home=/opt/tomcat-product-ooo/ 这里可以写死tomcat的绝对路径,也可以下一行获取 tomca...
2019-02-22 13:16:34
862
原创 Cannot open root device "nfs" or unknown-block(2,0): error -6
配置NFS时启动内核报错 Cannot open root device "nfs" or unknown-block(2,0): error -6在网上搜了各种办法,都没解决,内置menuconfig设置也是正确的后来发现自己的nfs配置手误写错了;vim /etc/exports中/home/rootfs *(rw,sync,no_root_squash,no_subtree_...
2019-02-22 00:13:48
3860
原创 IDEA中Terminal使用Git进行版本回退
push后发现想回退版本先查看需要回退的那个版本号,在IDEA下面的terminal中输入(终端相当于window 的cmd)先在gitlab上查看需要回退的那个版本号:94f7cf541428c12a13b5b94323cf0094d716840b在IDEA下面的terminal中输入(终端相当于window 的cmd) git reset --hard 94f7cf5414...
2019-02-21 17:16:53
568
原创 on duplicate key用法
存在即更新,不存在则插入如下sql执行,判断主键id,如果主键存在,则更新,不存在则插入;insert into t_magicbank_target_trans_out_record(oid,payee_address) values(3,'aa') on duplicate key update payee_address=VALUES(payee_address)一定得主键或唯...
2019-02-21 15:02:20
4047
原创 用Qemu模拟vexpress-a9记录
环境介绍: ubuntu16.04 64+mac+vmware fusion 11u-boot版本:u-boot-2017.05交叉编译工具链:arm-linux-gnueabi-busybox版本:1.27.0Linux kernel版本:linux-4.4.174一. 安装uboot-tools/交叉编译工具等apt install u-boot-toolsapt instal...
2019-02-21 00:22:08
1085
原创 关于信号量的思考
java中提供的信号量实现Semaphore类初始化10个信号量 Semaphore sem = new Semaphore(10);获取信号量 sem.acquire(2);入门级案例 private static final Integer SEM_MAX = 1; public static void main(String[] args) { ...
2019-02-19 10:46:41
147
原创 Linux下C语言基础——arm交叉编译器安装
ubuntu 16.04下输入该命令apt install gcc-arm-linux-gnueabi重新编译main.c文件-arm-linux-gnueabi-gcc -o mian main.c执行main,如果是原来的gcc编译器会正常执行,但现在用的是arm编译器提示:...
2019-02-17 00:18:08
1247
原创 Linux下c语言基础——线程
先上一段代码hello.cvoid thread01(void){ int i; for(i=0;i<3;i++) { printf("this is a pthread01.\n"); sleep(1); }}void thread02(void){ int i; for(i=0;i<...
2019-02-15 17:33:43
185
原创 java值传递与C语言的指针变量
1.java中的形参值传递 public static void main(String[] args) { Integer a=1,b=3; swap(a,b);//将a,b对象的地址值传递给形参,方法中形参交换地址值 System.err.println("a="+a+",b="+b); } static void swap(In...
2019-02-15 11:34:34
481
原创 Linux下c语言基础——makefile
一个头文件,两个c文件main.c test1.c test1.htest1.h头文件,负责申明函数,引入依赖#ifndef _MYTOOL_1_H #define _MYTOOL_1_H #include &amp;lt;stdio.h&amp;gt;void mytool1_print(char *print_str);#申明函数#endif~ test1.c 实现...
2019-02-14 18:42:36
192
原创 ServletContext类getRealPath()不兼容jar形式
ServletContext接口提供了几个获取项目路径的方法其中getRealPath是可以获取容器在服务器中的绝对位置 public String getRealPath(String path);问题:最近在项目中遇到一个问题,依赖的第三方jar中有一个Filter在其init()调用了filterConfig.getServletContext().getRealPath("/...
2019-02-14 14:43:36
460
1
原创 装饰者模式——Decorator
动态地给一个对象添加一些额外的职责。就增加功能来说, Decorator模式相比生成子类更为灵活。该模式以对客 户端透明的方式扩展对象的功能。(组合优先于继承)1.Component(被装饰对象的接口)定义一个对象接口,可以给这些对象动态地添加职责。2.ConcreteComponent(具体被装饰对象)定义一个对象,可以给这个对象添加一些职责。3.Decorator(装饰者抽象...
2019-02-13 17:38:24
111
原创 ThreadLocal应用场景(一)
ThreadLocal,叫做线程本地变量,或叫做线程本地存储,ThreadLocal为变量在每个线程中都创建了一个副本,每个线程可以访问自己内部的副本变量。应用场景:数据连接等线程私有对象Mybatis 中用到的ThreadLocal,如下:private static final ThreadLocal&lt;ErrorContext&gt; LOCAL = new ThreadLoc...
2019-02-13 16:43:46
1463
原创 springboot+rabbitMQ入门(一)
springboot1.5.4+rabbitMQ前提:可以通过docker在vm虚拟机上生成镜像容器,非常便捷pom <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-start...
2019-02-05 23:02:19
148
原创 设计模式——策略模式应用
公司的Auth服务使用了策略模式来实现对不同算法的动态处理,学习一下先盗图一张,模式图如下先定义一个Strategy接口 public interface AuthStrategy{ //用于动态匹配策略 match(str); //执行鉴权操作 doAuth(); }定义几个不同的实现类:@Componentpublic class Use...
2019-02-02 10:36:04
166
原创 springboot注入@autowire——Map/List
平常业务中一般都是单实现类,最近研究下了一个接口多实现的用途1.定一个接口(案例)public interface PersonService { void doWork();}2.两个(或多个)实现,具体实现的方法体不同;@Service("studentService")public class StudentServiceImpl implements Perso...
2019-02-01 21:42:50
11025
5
原创 SpringCloud-Zuul实战(一)
springboot2.0.3+cloud Finchley.RELEASE版本先保持统一pom <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-c...
2019-02-01 19:02:50
521
原创 springboot2.0.3+Finchley.RELEASE注意点
1.注册中心eureka-server1.1 pom.xml&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&amp;lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:x
2019-02-01 10:21:24
498
原创 mybatis plus入坑2
对应数据库Date类型字段,在xml中可以这样写; <if test="showTime!= null" > show_time= #{show_time,jdbcType=Date}, </if>但如果是plus需要在代码中,手动进行格式化,对应一个表进行通过date字段查某些记录,其实这样写并不如动态sql来的简洁;tWrap...
2019-01-31 17:09:15
254
转载 Logback使用记录一下
LOGBACKspringboot 添加依赖,该依赖自带logback。 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>...
2019-01-30 17:51:21
107
原创 springboot2.x整合redis踩坑
几个重点springboot2.x &amp;amp;amp;lt;parent&amp;amp;amp;gt; &amp;amp;amp;lt;groupId&amp;amp;amp;gt;org.springframework.boot&amp;amp;amp;lt;/groupId&amp;amp;amp;gt; &amp;amp;amp;
2019-01-30 16:56:42
3923
原创 springboot整合mybatis plus实战一
Mybatis Plus现在公司用的内部的mybatisGenerate生成工具,可以生成单表的CRUD的xml,domian,dto,cond(查询条件),但是存在一个问题,就是修改表字段的,那xml需要重新生成并替换,如果sql xml中有自定义的sql那容易被覆盖或遗漏,所有学习了下mybatis Plus依赖 &lt;dependency&gt; &l...
2019-01-30 15:31:35
2011
原创 go语言gorm使用
持久层框架gorm——数据库配置var jsonData map[string]interface{}//全局变量:存放配置文件的map对象func initJSON() { bytes, err := ioutil.ReadFile("./configuration.json")//读取全局配置文件 if err != nil { fmt.Println("ReadFile: "...
2019-01-28 15:01:11
3187
1
原创 Go语言知识点
grom查询——带条件查询 db.Where(&User{Name: "jinzhu", Age: 20}).First(&user)//// SELECT * FROM users WHERE name = "jinzhu" AND age = 20 LIMIT Go 语言中 UTF-8 包提供的 RuneCountInString() 函数,统计 Uncode 字...
2019-01-28 14:41:58
238
1
转载 go语言传递指针对象、传递值对象区别
传递指针和对象的区别package mainimport "fmt"type T struct { Name string}func (t T) M1() {//传入变量的名字 t.Name = "name1"}func (t *T) M2() {//传入地址 t.Name = "name2"}func main() { t1 := &T{"t1"} f...
2019-01-25 12:54:27
1075
原创 spring通过Map动态获取接口的实现类
在一些业务场景下,我们需要根据不同的策略调用统一接口的实现类,这里可以使用Map注入来实现注入一个map,key对应不同的策略 @Autowired private Map<String,UserService> userMap;定义两个不同的实现类——实现UserService//实现类1-对应策略1@Component("commonUser")public...
2019-01-25 09:20:43
2099
原创 go语言接口使用
go语言中没有java中的extends,也没有class的概念,“继承”的概念体现的结构体struct文件的方法中package mainimport ( "fmt")// 定义接口,// 该接口可以定在在该文件类或者其他文件夹内,类型java的接口,只定义方法,没有实现type LessAdder interface { GetById(id int64) Product ...
2019-01-24 22:19:38
401
原创 mysql日期Date类型与Java匹配
插入与查找数据库Date类型的方法两种:date_format(#{endTime},’%Y%m%d’) 将Dao层传入的Date对象再xml中格式化create_date=#{endTime,jdbcType=DATE} 这个简单些。
2019-01-24 10:39:58
1634
1
原创 Pagehelper使用
依赖&lt;!-- 分页插件 --&gt; &lt;dependency&gt; &lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt; &lt;artifactId&gt;pagehelper-spring-boot-starter&
2019-01-23 09:23:19
1540
原创 动态sql注意点1.0
动态sql注意点1.0<if test="queryDate!=null "> and last_update=date_format(#{queryDate},'%Y%m%d')</if>时间参数是不需要写queryDate!=‘’的,if中需要加and
2019-01-16 09:31:13
92
原创 springboot配置redis 测试jun异常
junit测试redis异常问题解决java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=testsetString], {ExactMatcher:fDisplayName=testsetString(com.example.VkeIocRedisApplicationTests)], {Leading...
2018-10-05 22:50:11
510
原创 Shiro
[shiro] Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.-在 采用经典的权限模型,即RBAC(RoleBased Access Control )基于角色的访问控制(员工-角色-菜单),添加/修改员工状态时出现异常,发现是菜单表中该用户对应的角色...
2018-09-27 19:48:35
86
原创 首尝springboot(测试demo)
Springboot Demo今日首次亲手尝试了下springboot框架的高效之处: 最少的安装时间,创建一个可以运行在生产环境的spring应用程序访问http://start.spring.io/点击Generate Project下载项目压缩包解压后,使用eclipse,Import -> Existing Maven Projects -> Nex...
2018-09-16 22:03:54
292
原创 Mybatis 核心config及mapper配置注意事项
sqlConfig.xml 配置如下<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <c
2018-09-01 12:06:58
196
原创 Maven中使用Mybatis出现的异常处理(一)
Exception:ClassNotFoundException: org.apache.ibatis.io.Resources1. servlet中条用DBcon访问sqlMapConfig.xmlimport java.io.IOException;import java.io.InputStream;import org.apache.ibatis.io.Resources;...
2018-08-30 09:34:42
723
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人