在进行springboot整合security的时候,出现以下错误:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Illegal overloaded getter method with ambiguous type for property enabled in class class com.springboot.security.entity.User. This breaks the JavaBeans specification and can cause unpredictable results.
原因:在做用户登录的时候,通常我们会判断当前账号是否可用,将这个属性设置为Boolean类型。而我们定义好的类需要实现UserDetails 接口来规范用户属性,然后重写里面的方法来判断当前的用户是否可用。这时候重写的isEnabled方法就会跟Mybatis自动生成的getEnabled方法同时存在。
解决方法:因为isEnable相当于getEnable,导致JavaBean里面有两个getEnabled方法,违反了JavaBean的规范,只要将其中一个删掉就可以了