2017-08-07 53 views
0

我遇到了iBatis的這個綁定問題。這是我的項目的結構:我想在Device.xml映射DeviceDaoiBatis與Maven的映射器綁定異常

enter image description here

。這是我在Device.xml中做到的。

<mapper namespace="service.dao.DeviceDao"> 

但是,當我嘗試訪問它時,會引發此錯誤。

"errorMessage": "Type interface service.dao.DeviceDao is not known to the MapperRegistry.","errorType": "org.apache.ibatis.binding.BindingException" 

我試着將它改爲smartcontrol.service.dao.DeviceDao,但仍然沒有工作。

我不明白的是,爲什麼Device 對象的引用位置沒有引起任何問題?

,我談到Configurations.xml被引用

<typeAliases> 
    <typeAlias alias="Device" type="server.pojo.Device"/> 
</typeAliases> 

設備位於下server.pojo

enter image description here

你看,他們service.dao.DeviceDao的設備對象和server.pojo.Device都位於samples/src/main/java/smartcontrol下。那麼,爲什麼在引用service.dao.DeviceDao時存在問題,而server.pojo.Device沒有問題?

回答

0

「的errorMessage」: 「類型接口service.dao.DeviceDao是不知道的 MapperRegistry。」, 「ERRORTYPE」: 「org.apache.ibatis.binding.BindingException」

這意味着映射器未在主MyBatis配置文件中註冊。更多信息:http://www.mybatis.org/mybatis-3/configuration.html#mappers