- 博客(230)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 to change:杂
JSON.parseArray(JSON.parseObject(provincesJson).getString(“data”),Province.class)
2018-11-22 16:08:41
440
原创 ex:redis实际使用
怎样把数据存储到redis里的session?分布式应用中怎样共享session?析:可以使用redis,见https://www.cnblogs.com/xuyatao/p/8080430.html怎样方法上使用redis缓存?析:https://blog.youkuaiyun.com/tonghuawanli/article/details/84070084...
2018-11-15 16:54:34
916
原创 spring boot配置 Redis
pom依赖: <dependency> <groupId>org.springframework.boot</groupId&a
2018-11-14 17:14:14
420
原创 spring boot配置Mybatis
先在pom.xml中加上mybatis的依赖:<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId&a
2018-11-12 14:42:20
235
转载 learn:redis概述
Redis以内存作为数据存储介质,所以读写数据的效率极高。Redis跟memcache不同的是,储存在Redis中的数据是持久化的,断电或重启后,数据也不会丢失。因为Redis的存储分为内存存储、磁盘存储和log文件三部分,重启后,Redis可以从磁盘重新将数据加载到内存中,这些可以通过配置文件对其进行配置,正因为这样,Redis才能实现持久化。Redis支持主从模式,可以配置集群,这样更利于...
2018-11-05 11:15:45
189
原创 exp:分布式限流
本部分是采用分布式每个节点单独控制限流的方式。// RateLimiterAnno.javaimport java.lang.annotation.ElementType;import java.lang.annotation.Inherited;import java.lang.annotation.Retention;import java.lang.annotation.Rete...
2018-10-19 11:55:40
234
原创 ex:并发编程经(1)
ConcurrentHashMap是支持并发的,但是如下代码有啥问题?private final Map<String, RateLimiter> limiterMap = new ConcurrentHashMap<>();// 并发使用的方法public void someMethod(){ if (!limiterMap.containsKe
2018-10-14 21:59:05
166
原创 ex:Redis使用代码
代码:import org.springframework.data.redis.core.StringRedisTemplate;private StringRedisTemplate stringRedisTemplate;比如Redis中存放的是set,// members()里是Redis里的key,set是对应的valueSet<String&a
2018-10-14 21:29:22
441
转载 ex :Redis安装及初步使用
先安装home brew:如果本机上安装了brew但需要更新,容易出现各种错误。好的做法:在https://stackoverflow.com/questions/46459152/cant-chown-usr-local-for-homebrew-in-osx-10-13-high-sierra网页上给出了解决办法,下面简单总结一下:先卸载已安装的homebrew,命令如下:/usr/bi...
2018-09-28 16:57:15
412
原创 exp:切面编程
简单实例:http://www.spring4all.com/article/258https://www.cnblogs.com/hq233/p/6637488.html
2018-09-18 17:56:59
219
原创 exp:curl命令
http请求比如get请求,curl http://mmm.in/cancel?applyId=631在命令行即可执行。如果有多个get请求,就把所有的请求放在文件里,curl http://mmm.in/cancel?applyId=631curl http://mmm.in/cancel?applyId=632全部复制到命令行执行。...
2018-09-18 17:29:41
210
原创 序列化
Serializable接口,Json序列化等。什么是序列化? 把在内存中的各种对象的状态(也就是实例变量,不是方法)保存下来,并且可以在需要时再将对象恢复。序列化就是将对象的状态写入字节流里。什么时候需要序列化? 析:对象存储到文件(数据库等)或网络传输时需要用到。如果没有序列化,看例子 https://blog.youkuaiyun.com/u011568312/article/detail...
2018-09-03 18:10:17
148
原创 exp: 对象池化
可以利用commons-pool2自定义对象池。看个例子,https://blog.youkuaiyun.com/qq447995687/article/details/80233621有个实体类T,工厂类TFactory,运行池类TPool工厂类作用?有哪些方法?析:创建实体对象 create() ;把对象池化,是对对象的一个包装,加上了对象的一些其他信息,包括对象的状态(已用、空闲),...
2018-08-22 15:46:28
214
原创 exp: Http工具类
HttpClientUtils.java 见: https://github.com/lifan2/lfLearn/blob/master/src/main/java/com/lflearn/httpLearn/HttpClientUtils.java几个问题:
2018-08-21 16:59:24
232
原创 exp:postman测试
首先在浏览器进入需要的网站,在调试界面点击某个请求,发现可以找到类似login_sess的cookie,如下图: 这就是postman需要的cookie数据。 打开postman,输入一个domain name,比如叫 localhost,保存。 之后需要...
2018-08-10 14:47:14
474
转载 exp:并发处理 -规范
1.【强制】获取单例对象需要保证线程安全,其中的方法也要保证线程安全。 说明:资源驱动类、工具类、单例工厂类都需要注意。 2.【强制】创建线程或线程池时请指定有意义的线程名称,方便出错时回溯。 正例: public class TimerTaskThread extends Thread {public TimerTaskThread()...
2018-08-02 15:10:06
814
原创 exp:Linux命令
常用命令: http://linoxide.com/guide/linux-command-shelf.html;https://kb.iu.edu/d/afsk 文本处理命令: http://blog.jobbole.com/19641/;http://ahei.info/text-processing.htm
2018-08-02 10:23:29
2735
原创 exp:MyBatis使用
自动生成MyBatis-generator见: https://blog.youkuaiyun.com/tonghuawanli/article/details/76999282在Mapper类中,如果是有两个参数的方法,一定要在参数上加上@Param,例:VerifyOrderDO selectLatestVerifyOrder(@Param("userId") Long userId, @Par...
2018-08-01 14:24:52
252
原创 exp:一些代码规范 2018.7.20起
命名:类名多用名词,方法多用动词。 函数设计原则:短小,函数参数避免3个以上。 使用异常代替返回错误码。
2018-07-20 16:39:15
786
转载 exp:Http协议
http方法有: GET 请求获取Request-URI所标识的资源 POST 在Request-URI所标识的资源后附加新的数据 HEAD 请求获取由Request-URI所标识的资源的响应消息报头 PUT 请求服务器存储一个资源,并用Request-URI作为其标识 DELETE 请求服务器删除...
2018-07-15 23:07:07
414
转载 Session知识点
会话较多用于网络上,TCP的三次握手就创建了一个会话,TCP关闭连接就是关闭会话。 在打开浏览器第一次请求该jsp的时候,服务器会自动为其创建一个session,并赋予其一个sessionID,发送给客户端的浏览器。以后客户端接着请求本应用中其他资源的时候,会自动在请求头上添加:(Cookie:JSESSIONID=客户端第一次拿到的session ID)。这样,服务器端在接到请求时候,就会收到...
2018-07-13 14:23:11
256
原创 字符串分割成字串都是回文
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s =”aab”, Return [ [“aa”,”b”],
2017-09-11 11:32:26
378
原创 第k大的元素
析:借助快速排序的思想import java.util.Scanner;public class Main4 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String numStr=sc.nextLine(); String[] n
2017-08-26 17:26:29
381
原创 层次遍历、递归:jump-game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you
2017-08-19 17:02:28
494
原创 穷举法:max-points-on-a-line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 析:此处的在一条直线上也包含斜的直线,因此分为水平竖直线、斜线两种情况。 如果是水平竖直线,直接以横坐标或纵坐标为参考作统计即可; 如果是斜线,得先把斜线定义成Line类,包含k b两个值, 之
2017-08-19 15:18:08
388
原创 动态规划、递归:word-break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s =”catsan
2017-08-19 09:08:11
418
原创 动态规划:word-break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s =”leetcode”, dict =[“leet”, “co
2017-08-16 18:51:13
403
原创 exp:使用MyBatis-generator 自动生成MyBatis代码
在pom.xml中加上插件:<dependency> <groupId>org.mybatis.generator</groupId> &amp
2017-08-09 16:06:38
475
原创 spring boot 启动错误:Could not resolve placeholder
在启动整个spring boot项目时,出现错误: Could not resolve placeholder原因:没有指定好配置文件,因为src/main/resources下有多个配置文件,例如application-dev.properties, boss.properties等。解决办法: 法1: 在application.properties中加入 spring.profiles
2017-08-02 19:18:40
108783
8
原创 exp:Java生成excel
用到apache.poiHSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xlsXSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsxSXSSFWorkbook 是专门用来处理大量数据写入 Excel2007的问题的读取仍然是“XSSFWorkbook”,写入则为“SXSSFWorkbook”代码:1、自定义Excel注解类imp
2017-07-31 16:09:12
499
原创 exp: SpringBoot发送邮件功能
如果是发送纯文本邮件不带附件,可以直接用SimpleMailMessage例:import org.springframework.mail.javamail.JavaMailSender;import org.springframework.mail.SimpleMailMessage;@Autowiredprivate JavaMailSender mailSender;public vo
2017-07-27 21:33:28
505
原创 exp:Exception异常处理
自定义异常类:先看两个自定义异常:// 异常1class MyException extends Exception { public MyException(String msg) { super(msg); } }// 异常2public class BusinessRuntimeException extends Runtim
2017-07-27 11:58:25
1556
原创 exp:CST格式的字符串转化为Date对象
CST格式:例如Tue Jul 25 17:26:48 CST 2017方法:String cstString ="Tue Jul 25 17:26:48 CST 2017";String CST_FORMAT = "EEE MMM dd HH:mm:ss z yyyy";Date cstDate = new SimpleDateFormat(CST_FORMAT, Locale.US).par
2017-07-25 19:02:20
844
1
tomcat 出现错误,急求!!!!!!!!!!!!!!!!!
2016-06-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人