错误 : java.lang.IllegalStateException: Mapping is missing column attribute for property dept
1. 错误背景在SSM框架的使用过程中,书写mapper.xml文件的过程中出现的低级错误 .2. 错误信息java.lang.IllegalStateException: Mapping is missing column attribute for property deptorg.apache.ibatis.mapping.ResultMappingBuilder.validate(Resu
1. 错误背景
- 在SSM框架的使用过程中,书写mapper.xml文件的过程中出现的低级错误 .
2. 错误信息
java.lang.IllegalStateException: Mapping is missing column attribute for property dept
org.apache.ibatis.mapping.ResultMapping
B
u
i
l
d
e
r
.
v
a
l
i
d
a
t
e
(
R
e
s
u
l
t
M
a
p
p
i
n
g
.
j
a
v
a
:
155
)
o
r
g
.
a
p
a
c
h
e
.
i
b
a
t
i
s
.
m
a
p
p
i
n
g
.
R
e
s
u
l
t
M
a
p
p
i
n
g
Builder.validate(ResultMapping.java:155) org.apache.ibatis.mapping.ResultMapping
Builder.validate(ResultMapping.java:155)org.apache.ibatis.mapping.ResultMappingBuilder.build(ResultMapping.java:140)
org.apache.ibatis.builder.MapperBuilderAssistant.buildResultMapping(MapperBuilderAssistant.java:391)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:392)
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:279)
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:253)
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:245)
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
等等…
非常难受的是Mapper 里面错误后会抛出N多个错误例如:
-
Error creating bean with name ‘employeeController’: Unsatisfied dependency expressed through field ‘employeeService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘employeeServiceImpl’: Unsatisfied dependency expressed through field ‘employeeMapper’
-
Error creating bean with name ‘employeeServiceImpl’: Unsatisfied dependency expressed through field ‘employeeMapper’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘employeeMapper’ defined in file [D:\IdeaProjects\3-10-15-rbac\target\classes\cn\wolfcode\rbac\mapper\EmployeeMapper.class]: Invocation of init method failed;
-
Error creating bean with name ‘employeeMapper’ defined in file [D:\IdeaProjects\3-10-15-rbac\target\classes\cn\wolfcode\rbac\mapper\EmployeeMapper.class]: Invocation of init method failed;
-
Error parsing Mapper XML. The XML location is ‘cn/wolfcode/rbac/mapper/EmployeeMapper.xml’. Cause: java.lang.IllegalStateException: Mapping is missing column attribute for property dept
org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:83) -
(真正的错误原因) Error parsing Mapper XML. The XML location is ‘cn/wolfcode/rbac/mapper/EmployeeMapper.xml’. Cause: java.lang.IllegalStateException: Mapping is missing column attribute for property dept.
-
(真正的错误原因) java.lang.IllegalStateException: Mapping is missing column attribute for property dept(映射缺少属性, 部门的列属性.)
-
一定要找到错误的真正原因: 属性省缺少列属性。
3. 错误代码
<resultMap id="BaseResultMap" type="cn.xxxxxx.rbac.domain.Employee" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="age" property="age" jdbcType="INTEGER" />
<result column="admin" property="admin" jdbcType="INTEGER" />
<result column="deptId" property="deptId" jdbcType="BIGINT" />
<association property="dept" select="cn.xxxxxxxx.rbac.mapper.DepartmentMapper.selectByPrimaryKey"></association>
</resultMap>
4. 解决方法
- 最后一行的代码中缺少了一个column 属性
- 更改之后的代码:
//修改的地方在这
select="cn.xxxxxxx.rbac.mapper.DepartmentMapper.selectByPrimaryKey" column="deptId"></association>
</resultMap>
如有错误请各位大神指导,叩谢了!!!
更多推荐
所有评论(0)