spring boot项目中使用了 mybatis 级联查询,返回 json 格式时报错
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory
E
n
h
a
n
c
e
d
R
e
s
u
l
t
O
b
j
e
c
t
P
r
o
x
y
I
m
p
l
]
;
n
e
s
t
e
d
e
x
c
e
p
t
i
o
n
i
s
c
o
m
.
f
a
s
t
e
r
x
m
l
.
j
a
c
k
s
o
n
.
d
a
t
a
b
i
n
d
.
e
x
c
.
I
n
v
a
l
i
d
D
e
f
i
n
i
t
i
o
n
E
x
c
e
p
t
i
o
n
:
N
o
s
e
r
i
a
l
i
z
e
r
f
o
u
n
d
f
o
r
c
l
a
s
s
o
r
g
.
a
p
a
c
h
e
.
i
b
a
t
i
s
.
e
x
e
c
u
t
o
r
.
l
o
a
d
e
r
.
j
a
v
a
s
s
i
s
t
.
J
a
v
a
s
s
i
s
t
P
r
o
x
y
F
a
c
t
o
r
y
EnhancedResultObjectProxyImpl]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory
EnhancedResultObjectProxyImpl];nestedexceptioniscom.fasterxml.jackson.databind.exc.InvalidDefinitionException:Noserializerfoundforclassorg.apache.ibatis.executor.loader.javassist.JavassistProxyFactoryEnhancedResultObjectProxyImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.HashMap[“rows”]->java.util.ArrayList[0]->(包名.类名)_$$_jvstef3_1[“handler”])
需要在查询涉及的类上加上注解@JsonIgnoreProperties(value={“hibernateLazyInitializer”,“handler”})
作用是在 json 序列化时忽略 bean 中的一些不需要转化的属性
感谢两位博主
https://blog.csdn.net/a57565587/article/details/43151239
https://blog.csdn.net/Victoria__W/article/details/83146557