Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type.

When interface testing encountered a problem, causing the test to block for a long time, in this record, beware forget.

具体报错如下:
Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

Interface error .png

Interface test code as follows:

Pictures .png

The problem is this pId,
Baidu the cause of this problem, in the final analysis is the wrong type of parameters:

The optional parameter pId does not exist, but can not be converted to NULL, because you gave it to define the base type. It is proposed to amend the package type.

That is, you define the parameters: String pId, but no value, it intuitively, according to null to deal with, the result of bad things to come: pId = null; is not allowed, because the underlying type can not be assigned to null.
It is proposed to modify the parameter is defined as Inteter pId.


Why Integer that can be used with int not do it for the following reasons:

Integer values ​​can be null, int default 0, if the database which has no value field may default value is null, so use Integer.

In hashmap can only use Integer rather than using int

int is the basic data type, a definition of integer data. Integer is a class that represents an object in the hashmap, it is denoted by the object.

Original Address: https: //www.jianshu.com/p/1153070468e1

When interface testing encountered a problem, causing the test to block for a long time, in this record, beware forget.

具体报错如下:
Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

Interface error .png

Interface test code as follows:

Pictures .png

The problem is this pId,
Baidu the cause of this problem, in the final analysis is the wrong type of parameters:

The optional parameter pId does not exist, but can not be converted to NULL, because you gave it to define the base type. It is proposed to amend the package type.

That is, you define the parameters: String pId, but no value, it intuitively, according to null to deal with, the result of bad things to come: pId = null; is not allowed, because the underlying type can not be assigned to null.
It is proposed to modify the parameter is defined as Inteter pId.


Why Integer that can be used with int not do it for the following reasons:

Integer values ​​can be null, int default 0, if the database which has no value field may default value is null, so use Integer.

In hashmap can only use Integer rather than using int

int is the basic data type, a definition of integer data. Integer is a class that represents an object in the hashmap, it is denoted by the object.

Original Address: https: //www.jianshu.com/p/1153070468e1

Guess you like

Origin www.cnblogs.com/jpfss/p/11447128.html