自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(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 2081

原创 Refactoring 简化嵌套循环

嵌套循环有时会影响性能,最近写的代码,有一个双层list for each需要被简化,特此记录一下原代码:model:ParentList- ParentElement - ChildList - ChildElementList<SampleClass> function(String languageCode, ParentList parentList){ List<SampleClass> list ...

2020-05-14 21:52:32 176

原创 使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 192

原创 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 3353

原创 把一个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 6532 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 113

原创 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 162

原创 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 245

原创 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 3094 4

原创 让Unit test 按代码中顺序执行

unit test 默认乱序执行,有时测试需要test case按顺序执行。在class前加上@FixMethodOrder(MethodSorters.JVM)可使test case一代码中顺序执行

2019-02-03 02:38:59 816

原创 Spring JPA + MySQL/H2 example

开始接触Spring JPA,分别用了in memory DB H2和MySql,整理如下:1.  Maven dependency:h2 和 mysql dependency 选其一就可以&lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/group...

2019-02-02 11:44:21 213

原创 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 491

原创 记一个发送json时遇到的同步异步问题

写了一个跳转流程如下:"php1" 跳转到 -&gt; "html1"进行账户确认操作并 redirect_to -&gt; "php2"在php1发送json格式的账户信息到php2php2对账户信息进行下一步操作但是php2报错说账户未确认后来才发现:还没执行跳转时php1就已经向php2发送了信息,php2收到信息就已经执行了,此时还没确认账户把发json改成了存...

2018-07-22 00:55:59 317

原创 PHP 生成文件

$sqlfile = fopen("sql.txt", "w")or die("Unable to open file!");fwrite($sqlfile, $insertUrl);fclose($sqlfile); 

2018-07-21 10:48:41 349

原创 PHP 发送 / 接收 JSON

Encode JSON:$jsonStr = json_encode(array('MID' =&gt; $result["MID"],'email' =&gt; $email, 'name' =&gt; $username, 'address' =&gt; $address, ...

2018-07-16 07:48:39 491

原创 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 198

原创 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 1520

原创 Iterator——迭代器

单向遍历并选择Container中的对象,不必暴露该对象内部细节的方法   - 创建IteratorList&lt;String&gt; commandLines = Files.readAllLines(Paths.get(commandFileName));Iterator&lt;String&gt; iter = commandLines.iterator();- Methods  - ...

2018-06-24 03:34:56 113

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除