这是一个测试 mybatis 的项目。
- 延迟加载出现错误
application.properties
lazy-loading-enabled=true
cause an error
nested exception is org.apache.ibatis.executor.ExecutorException: Error creating lazy proxy. Cause: java.lang.RuntimeException: icu.guodapeng.mybatisdemo.domain.entity.UserBase is final
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error creating lazy proxy. Cause: java.lang.RuntimeException: icu.guodapeng.mybatisdemo.domain.entity.UserBase is final
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
...
解决了方案:使用 kotlin-allopen 插件解决。与 CGLIB 的工作方式有关。
我不认识这个文章的作者,但是受到了他的帮助。