某个被lombok @Data修饰的DTO类,因为我加了一个public boolean isRecommended()
方法,报错了:
org.apache.ibatis.reflection.ReflectionException: Illegal overloaded getter method with ambiguous type for property recommended in class
class com.leyantech.codex.policy.bean.dto.ScenarioHolderDTO. This breaks the JavaBeans specification and can cause unpredictable results.
分析了一下原因,因为这个实体类有一个属性:private Integer recommended
,而lombok会自动给它加get、set方法。所以此类应该有一个isRecommended()
方法,和一个getRecommended()
方法,所以mybatis会报错:
Illegal overloaded getter method with ambiguous type for property recommended
结论:应该避免在此种类中定义get、set、is开头的方法
类似问题:SpringBoot整合SpringSecurity出现Illegal overloaded getter method with ambiguous type for property enable