Recent work record notes

1. Problem being given about jackson serialization:

错误信息类似:No serializer found for class com.topideal.supplychain.ocp.ymatou.converter.A and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

To the effect that there is no serializer found.

Internet that are provided in the configuration file as follows (New another new ObjectMapper () set properties) or switch to fastJson

spring.jackson.serialization.FAIL_ON_EMPTY_BEANS
The premise of this solution is that you give your private property getter method (setter does not require) the entity class, if your property is shared (public), you do not need this wave. Also, the need to ensure that the class has a default constructor

If you have the above error, you can use the online statement resolved.

Haha, this is just stressed the need for getter methods. Because now use inner builder plugin generates an internal constructor, you may forget to write.

2.java8 group objects according to an attribute

The objects according to an attribute group, the same attribute objects in a list

assumption Student existing set list List <Student> studentList, according to the age of the packet name

written before, studentList.stream (). Collect () . (Collectors .toMap (Student :: getAge, Student :: getName));

found behind the name of the previously covered, age and name is one to one.

I would like age and name are many

studentList.stream () the collect () (Collectors.toMap (getAge :: Student, Student -..> Lists.newArrayList (Student),

(List <String> newList, List <String> oldList) -> {oldList.addAll (newList);

return oldList;

}));
3.mybatis INSERT statement

mybatis插入语句一般都是这样写
<!-- useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中 -->
<insert id="insert" parameterType="xxx.xxx.xxx.xxx" keyProperty="id" useGeneratedKeys="true">,
useGeneratedKeys 取值范围true|false 默认值是:false。 含义:设置是否使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。
之前一直以为useGeneratedKeys="true"是让mysql数据库主键新增,其实是,插入语句后将id赋值给实体bean,即使用insert后,使用bean.getId()可以获得值,若是false,bean.getId()=null。不管true还是false,数据库插入的数据,都会自动生成主键(前提是设置自动增长主键)。

4.mysql default sort

myisam engine tables, without any deletion, the modifying operation, performed without a select order by, then are sorted by the insertion order;

innodb engine table, in the same circumstances, it will be sorted according to the primary key, from small to large.

5. With regard to the insertion sequence tag foreach Mybatis in question (bulk insert)

Foreach tag using bulk insert data, intervening sequence is not inserted in order (the order may be, reverse, random). To ensure that the data sequence [sort data insertion order with the same query], can be added rank data field in order to solve the problem, or the use of a single insert statement to ensure.

When 6.Mybatis flyers parameters, parameter xml sql statement can easily write, do not correspond with the method. The reason is that, MyBatis of variable parameters are [0,1, param1, param2] (multi-reference), may be used to determine @param annotations, single reference, MyBatis no special treatment, the parameter name {#} can be removed, parameter take random name.

7. A Template Method and Strategy Mode B

Template Method: Define an algorithmic, certain subclasses to achieve a delay

Strategy Mode: so that different algorithms can be substituted for each other - depending on the scenario. You MUST know all the policy, which specifies the scene that is using a strategy]

8. Project dependency problems

idea, a project A to another item B, only the addition of B in A Module1, traceable to the source of B (A B needs dependent version to version B into the same). [Mvn clear / install the A to B]

9.easyui framework, using the dialog to load html pages, written in the head js not executed, can be placed in the body, or set the delay time setInterval.

dialog pop Data disorder (multi-level pop), Solution: Open dialog div tags are written in the outermost page (parent page).

10.idea deployed on tomcat

. A start Deployment Artifact selected next item arranged in tomcat, to select the end explorded (this is not selected, the following can not be selected);

b. Then in the Server On "update" action Select update classes and resources

c. To modify url, to simultaneously modify Deployment of Application context, consistent.

11.idea if Bean attribute type "pMsg", generated getter / setter, was getpMsg / setpMsg, p lowercase, if forced to uppercase, from page post by value (json), the background @RequestBody reception, this upon receiving the value of the attribute not

Guess you like

Origin www.cnblogs.com/carl-cn/p/12060165.html