关于mybatis:mybatis-懒加载中的错误

4次阅读

共计 995 个字符,预计需要花费 3 分钟才能阅读完成。

org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
解决方案
yml 文件中

spring:
  jackson:
    serialization:
     FAIL_ON_EMPTY_BEANS: false

properties

spring.jackson.serialization.fail-on-empty-beans=false

敞开该查问的懒加载 fetchType="eager"

 上面的两种办法我也试过,如同并没有什么作用,在进行序列化的时候就会呈现问题比如说 BackstageRole 会变成 Backstage_$$_jvst12a_0 这种代理对象(非原始对象)。
<resultMap id="RoleMap" type="com.hyper.netman.entity.business.BackstageRole">
        <result column="id" property="id"/>
        <result column="role_name" property="roleName"/>
        <result column="role_desc" property="roleDesc"/>
        <result column="create_time" property="createTime"/>
        <result column="modify_time" property="modifyTime"/>
        <!-- 须要敞开懒加载,不然对象不是原来的对象 -->
        <collection property="resources" column="id" javaType="list" fetchType="eager" select="getRolesMenus"/>
</resultMap>
  1. 返回的类加上注解(即实体类)
@JsonIgnoreProperties(value = { "handler"})
public class BackstageRole{}
正文完
 0