- 博客(18)
- 收藏
- 关注
原创 正则表达式中?:的作用
正则表达式中?:的作用在正则表达式中使用括号()会在匹配时创建相应的group, 例如日期匹配regex:/^(\d{4})[-/](\d{2})[-/](\d{2})$/括号包裹的三个部分会生成3个group,如下图可以用$1, $2和 $3获取各group,如:String str = "2021/04/24";String regex = "^(\d{4})[-/](\d{2})[-/](\d{2})$";str.replaceAll(regex,"$1年$2月$3日");替换后
2021-04-25 08:26:15 2139
原创 Refactoring 简化嵌套循环
嵌套循环有时会影响性能,最近写的代码,有一个双层list for each需要被简化,特此记录一下原代码:model:ParentList- ParentElement - ChildList - ChildElementList<SampleClass> function(String languageCode, ParentList parentList){ List<SampleClass> list ...
2020-05-14 21:52:32 178
原创 使Spring WebServices log SOAP request
将以下configuration放在 application.yml 里logging: level: org.springframework.ws.client.MessageTracing.sent: trace org.springframework.ws.client.MessageTracing.received: trace
2020-02-26 01:52:11 196
原创 Junit 验证exception的几种方法
try - catch @Testpublic void testInvalidData() { prepareTestData(); try { userService.fetchUser(1234); Assert.fail("IllegalArgumentException not thrown"); } catch (I...
2020-02-22 04:15:26 3393
原创 把一个LIst转换成另一个List的两种方法
Method 1:myFinalList = new ArrayList<>();myListToParse.stream() .filter(elt -> elt != null) .forEach(elt -> myFinalList.add(doSomething(elt)));Method 2:myFinalList...
2020-02-22 01:01:49 6600 1
原创 Set value for @Value in Spring Test
@Beforepublic void setup() { ReflectionTestUtils.setField(ObjectToTest,"fieldName",value);}You can set private variable in Test now without using Setter
2019-09-20 00:05:47 140
原创 InteliJ --Unable to parse template "Class"
Error Message:Unable to parse template "Class"Error message: selected class file name <file name>mapped to not java file type "Text".遇到的一个很小,却可以break整个project的问题。。。在项目文件里一个类前面符号变成了灰...
2019-08-19 08:52:15 171
原创 Resilience4J Demo Project
Resilience4J原Po介绍:Resilience4j is a lightweight fault tolerance library inspired byNetflix Hystrix, but designed for Java 8 and functional programming.主要元素CircuitBreaker Retry TimeLimiter...
2019-08-09 12:51:04 253
原创 Angular初始化时的 ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. no
用Angular CLI初始化了一个app以后ng serve时出现以下ERROR:ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected...
2019-02-18 10:19:30 3155 4
原创 让Unit test 按代码中顺序执行
unit test 默认乱序执行,有时测试需要test case按顺序执行。在class前加上@FixMethodOrder(MethodSorters.JVM)可使test case一代码中顺序执行
2019-02-03 02:38:59 842
原创 Spring JPA + MySQL/H2 example
开始接触Spring JPA,分别用了in memory DB H2和MySql,整理如下:1. Maven dependency:h2 和 mysql dependency 选其一就可以<dependencies> <dependency> <groupId>org.springframework.boot</group...
2019-02-02 11:44:21 222
原创 Error Code: 1175.
MySQL Workbench UPDATE 时报错:Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferen...
2018-07-22 22:23:08 499
原创 记一个发送json时遇到的同步异步问题
写了一个跳转流程如下:"php1" 跳转到 -> "html1"进行账户确认操作并 redirect_to -> "php2"在php1发送json格式的账户信息到php2php2对账户信息进行下一步操作但是php2报错说账户未确认后来才发现:还没执行跳转时php1就已经向php2发送了信息,php2收到信息就已经执行了,此时还没确认账户把发json改成了存...
2018-07-22 00:55:59 341
原创 PHP 生成文件
$sqlfile = fopen("sql.txt", "w")or die("Unable to open file!");fwrite($sqlfile, $insertUrl);fclose($sqlfile);
2018-07-21 10:48:41 359
原创 PHP 发送 / 接收 JSON
Encode JSON:$jsonStr = json_encode(array('MID' => $result["MID"],'email' => $email, 'name' => $username, 'address' => $address, ...
2018-07-16 07:48:39 505
原创 Design Pattern-Decorator
Design Pattern ↳Structural ↳Decorator Main idea: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending ...
2018-07-05 23:34:36 227
原创 CSS引入外部字体
1. 字体网站下载font-face2. 将eot,woff,ttf,svg 放入工程文件夹中3. css 中添加font-face@font-face { font-family:"Intro-Inline"; src:url("./fonts/Intro_Inline.eot") format("eot"), url("./fonts/Intro_Inline.woff...
2018-06-29 02:19:47 1534
原创 Iterator——迭代器
单向遍历并选择Container中的对象,不必暴露该对象内部细节的方法 - 创建IteratorList<String> commandLines = Files.readAllLines(Paths.get(commandFileName));Iterator<String> iter = commandLines.iterator();- Methods - ...
2018-06-24 03:34:56 121
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人