我正在尝试使用xml将下面的datatable转换为pojo类,但是当我的测试运行时,我得到以下错误。我不知道为什么表没有Map。这个 customerId
出现在pojo类中。
错误:
cucumber.runtime.CucumberException: No such field learning.pojo.customerId
台阶特征:
And the user imported the following product file
| customerId | ....
|customer1 | ....
步骤java:
@When("^the user imported the following product file$")
public void uploadFile(DataTable table) throws IOException {
Example productImportFileModel = table.asList(Example.class).get(0);
根pojo:
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"products"
})
public class Example{
@JsonProperty("products")
private List<Products> products = null;
@JsonProperty("products")
public List<Products> getProducts() {
return products;
}
@JsonProperty("products")
public void setProducts(List<Products> products) {
this.products = products;
}
}
产品pojo:
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"customerId",
.....
.....
.....
.....
.....
})
public class Products {
@JsonProperty("customerId")
private String customerId;
@JsonProperty("customerId")
public String getCustomerId() {
return customerId;
}
@JsonProperty("customerId")
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
.....
.....
.....
.....
.....
}
1条答案
按热度按时间lf3rwulv1#
的json表示
Example
是:的json表示
Products
是:表作为列表的json表示为:
因此,请考虑使用:
或者更好:
您可以通过请求jackson提供json表示来调试它: