繁体   English   中英

Spring 在行动“java:不兼容的类型”

[英]Spring in Action "java: incompatible types"

我最近开始学习 spring,在手册中遇到了问题。 本例开发环境提示错误“java: incompatible types”:

private void saveIngredientRefs(
        long tacoId, List<IngredientRef> ingredientRefs) {
    int key = 0;
    for (IngredientRef ingredientRef : ingredientRefs) {....}

方法从这里调用:

saveIngredientRefs(tacoId, taco.getIngredients());

Class IngredintRef:

 @Data
public class IngredientRef {
    private final String ingredient;
}

class 炸玉米饼:

 @Data
public class Taco {
    private Long id;
    private Date createdAt= new Date();
    @NotNull
    @Size(min = 5, message = "message")
    private String name;
    @NotNull
    @Size(min = 1, message = "message")
    private List<Ingredient> ingredients;
}

和 class 成分:

    @Data
public class Ingredient {
    private final String id;
    private final String name;
    private final Type type;

    public enum Type{
        WRAP, PROTEIN, VEGGIES, CHEESE, SAUCE
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM