在作用戶登陸的時候,一般咱們會判斷當前帳號是否可用,將這個屬性設置爲Boolean類型。而咱們定義好的JavaBean須要實現UserDetails 接口來規範用戶屬性,而後重寫裏面的方法來判斷當前的用戶是否可用。這時候重寫的is方法就會跟Mybatis自動生成的getter方法同時存在。以下面的實例程序。java
public class Hr implements UserDetails {
private Boolean enabled;//帳號是否可用
public String getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
**
* 帳戶是否可用
* @return
*/
@Override
public boolean isEnabled() {
return enabled;
}
}
複製代碼
o.m.spring.mapper.MapperFactoryBean : Error while adding the mapper 'interface com.chb.vhr.mapper.HrMapper' to configuration. org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/chb/vhr/mapper/HrMapper.xml'. Cause: org.apache.ibatis.reflection.ReflectionException: Illegal overloaded getter method with ambiguous type for property enabled in class class com.chb.vhr.bean.Hr. This breaks the JavaBeans specification and can cause unpredictable results.spring
llegal overloaded getter method with ambiguous type for property enabled in class class com.chb.vhr.bean.Hr.
(該語句的意思是:Hr類中啓用的屬性類型不明確,非法重載getter方法)
由於isEnable至關於getEnable,致使JavaBean裏面有兩個getEnabled方法,違反了JavaBean的規範,只要將其中一個刪掉就能夠了。apache
聚沙成塔,滴水穿石!app