第一周
Date:7.29~8.04
- 异步任务的流程:使用消息队列,分别为记录到数据库、发送到消息队列、topic和tag加上框架连接、处理对应的业务逻辑
- postman 可以设置局部变量
- In the asynchronous callback test (there is one consumer online and one consumer local), since both consumers can handle messages, when an exception occurs, the two consumers will explode the heavy message exponentially. I choose to comment out my tag.
- list.stream().findFirst().orElse(null);
- List places = Arrays.asList(“Buenos Aires”, “Córdoba”, “La Plata”);
- List.sort(Comparator.comparingInt(Object::getPriority))
- map.forEach((k,v)->{System.out.println(k + " = " + v);});
创建普通内部类的代码如下:
Outer o = new Outer();
Outer.Inner inner = o.new Inner();
Outer.Inner inner = new o.Inner(); /* 错误 */
Outer.Inner inner = new Outer.Inner(); /* 错误 */
静态内部类没有外部对象的引用,所以它无法获得外部对象的资源,当然好处是,静态内部类无需依赖于
外部类,它可以独立于外部对象而存在。创建静态内部类的代码如下:
Outer.Inner inner = new Outer.Inner();
List cities = Arrays.asList(“Milan”,
“London”,
“New York”,
“San Francisco”);
String citiesCommaSeparated = String.join(",", cities);
System.out.println(citiesCommaSeparated);
//Output: Milan,London,New York,San Francisco
String citiesCommaSeparated = cities.stream()
.collect(Collectors.joining(","));
System.out.println(citiesCommaSeparated);
//Output: Milan,London,New York,San Francisco
Note: you can statically import java.util.stream.Collectors.joining if you prefer just typing “joining”.
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
Use MVC to receive JSON lists or sets: @RequestParam(“appId”) int appId,@RequestParam(value = “isTmp”, required = false) boolean isTmp,@RequestBody Set fileKeys;