Closed javaHBZ closed 1 year ago
这个问题升级到2.0.29应该就好了,你试试看
还是会出现这个问题
AbstractWrapper这个类的代码能提供下么?
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.30-SNAPSHOT/ 问题已经修复,请帮忙用2.0.30-SNAPSHOT版本验证,2.0.30版本预计在5月9日前发布
/*
import com.baomidou.mybatisplus.core.conditions.interfaces.Compare; import com.baomidou.mybatisplus.core.conditions.interfaces.Func; import com.baomidou.mybatisplus.core.conditions.interfaces.Join; import com.baomidou.mybatisplus.core.conditions.interfaces.Nested; import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments; import com.baomidou.mybatisplus.core.enums.SqlKeyword; import com.baomidou.mybatisplus.core.enums.SqlLike; import com.baomidou.mybatisplus.core.toolkit.*; import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils; import com.baomidou.mybatisplus.core.toolkit.sql.StringEscape;
import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiPredicate; import java.util.function.Consumer;
import static com.baomidou.mybatisplus.core.enums.SqlKeyword.*; import static com.baomidou.mybatisplus.core.enums.WrapperKeyword.APPLY; import static com.baomidou.mybatisplus.core.enums.WrapperKeyword.BRACKET; import static java.util.stream.Collectors.joining;
/**
@since 2017-05-26
*/
@SuppressWarnings({"serial", "unchecked"})
public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T, R, Children>> extends Wrapper
/**
@Override public T getEntity() { return entity; }
public Children setEntity(T entity) { this.entity = entity; return typedThis; }
protected Class
public Children setEntityClass(Class
@Override
public
@Override
public
@Override public Children eq(boolean condition, R column, Object val) { return addCondition(condition, column, EQ, val); }
@Override public Children ne(boolean condition, R column, Object val) { return addCondition(condition, column, NE, val); }
@Override public Children gt(boolean condition, R column, Object val) { return addCondition(condition, column, GT, val); }
@Override public Children ge(boolean condition, R column, Object val) { return addCondition(condition, column, GE, val); }
@Override public Children lt(boolean condition, R column, Object val) { return addCondition(condition, column, LT, val); }
@Override public Children le(boolean condition, R column, Object val) { return addCondition(condition, column, LE, val); }
@Override public Children like(boolean condition, R column, Object val) { return likeValue(condition, column, val, SqlLike.DEFAULT); }
@Override public Children notLike(boolean condition, R column, Object val) { return not(condition).like(condition, column, val); }
@Override public Children likeLeft(boolean condition, R column, Object val) { return likeValue(condition, column, val, SqlLike.LEFT); }
@Override public Children likeRight(boolean condition, R column, Object val) { return likeValue(condition, column, val, SqlLike.RIGHT); }
@Override public Children between(boolean condition, R column, Object val1, Object val2) { return doIt(condition, () -> columnToString(column), BETWEEN, () -> formatSql("{0}", val1), AND, () -> formatSql("{0}", val2)); }
@Override public Children notBetween(boolean condition, R column, Object val1, Object val2) { return not(condition).between(condition, column, val1, val2); }
@Override
public Children and(boolean condition, Consumer
@Override
public Children or(boolean condition, Consumer
@Override
public Children nested(boolean condition, Consumer
@Override public Children or(boolean condition) { return doIt(condition, OR); }
@Override public Children apply(boolean condition, String applySql, Object... value) { return doIt(condition, APPLY, () -> formatSql(applySql, value)); }
@Override public Children last(boolean condition, String lastSql) { if (condition) { this.lastSql.setStringValue(StringPool.SPACE + lastSql); } return typedThis; }
@Override public Children comment(boolean condition, String comment) { if (condition) { this.sqlComment.setStringValue(comment); } return typedThis; }
@Override public Children first(boolean condition, String firstSql) { if (condition) { this.sqlFirst.setStringValue(firstSql); } return typedThis; }
@Override public Children exists(boolean condition, String existsSql) { return doIt(condition, EXISTS, () -> String.format("(%s)", existsSql)); }
@Override public Children notExists(boolean condition, String notExistsSql) { return not(condition).exists(condition, notExistsSql); }
@Override public Children isNull(boolean condition, R column) { return doIt(condition, () -> columnToString(column), IS_NULL); }
@Override public Children isNotNull(boolean condition, R column) { return doIt(condition, () -> columnToString(column), IS_NOT_NULL); }
@Override public Children in(boolean condition, R column, Collection<?> coll) { return doIt(condition, () -> columnToString(column), IN, inExpression(coll)); }
@Override public Children notIn(boolean condition, R column, Collection<?> coll) { return not(condition).in(condition, column, coll); }
@Override public Children inSql(boolean condition, R column, String inValue) { return doIt(condition, () -> columnToString(column), IN, () -> String.format("(%s)", inValue)); }
@Override public Children notInSql(boolean condition, R column, String inValue) { return not(condition).inSql(condition, column, inValue); }
@Override public Children groupBy(boolean condition, R... columns) { if (ArrayUtils.isEmpty(columns)) { return typedThis; } return doIt(condition, GROUP_BY, () -> columns.length == 1 ? columnToString(columns[0]) : columnsToString(columns)); }
@Override public Children orderBy(boolean condition, boolean isAsc, R... columns) { if (ArrayUtils.isEmpty(columns)) { return typedThis; } SqlKeyword mode = isAsc ? ASC : DESC; for (R column : columns) { doIt(condition, ORDER_BY, () -> columnToString(column), mode); } return typedThis; }
@Override public Children having(boolean condition, String sqlHaving, Object... params) { return doIt(condition, HAVING, () -> formatSqlIfNeed(condition, sqlHaving, params)); }
@Override
public Children func(boolean condition, Consumer
/**
*/ protected Children not(boolean condition) { return doIt(condition, NOT); }
/**
*/ protected Children and(boolean condition) { return doIt(condition, AND); }
/**
*/ protected Children likeValue(boolean condition, R column, Object val, SqlLike sqlLike) { return doIt(condition, () -> columnToString(column), LIKE, () -> formatSql("{0}", SqlUtils.concatLike(val, sqlLike))); }
/**
/**
/**
/**
/**
/**
/**
@Override public void clear() { entity = null; paramNameSeq.set(0); paramNameValuePairs.clear(); expression.clear(); lastSql.toEmpty(); sqlComment.toEmpty(); sqlFirst.toEmpty(); }
/**
@Override public String getSqlSegment() { return expression.getSqlSegment() + lastSql.getStringValue(); }
@Override public String getSqlComment() { if (StringUtils.isNotBlank(sqlComment.getStringValue())) { return "/" + StringEscape.escapeRawString(sqlComment.getStringValue()) + "/"; } return null; }
@Override public String getSqlFirst() { if (StringUtils.isNotBlank(sqlFirst.getStringValue())) { return StringEscape.escapeRawString(sqlFirst.getStringValue()); } return null; }
@Override public MergeSegments getExpression() { return expression; }
public Map<String, Object> getParamNameValuePairs() { return paramNameValuePairs; }
/**
/**
@Override @SuppressWarnings("all") public Children clone() { return SerializationUtils.clone(typedThis); } }
好的 我去试试
出现了新的问题,我用的包的名称是 fastjson2-2.0.30-20230429.115149-8.jar
报错信息
### Error querying database. Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@747910e4, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@747910e4})'
### Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@747910e4, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@747910e4})'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96) ~[mybatis-spring-2.0.6.jar:2.0.6]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.sun.proxy.$Proxy80.selectList(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.sun.proxy.$Proxy82.selectList(Unknown Source) ~[na:na]
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:370) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:379) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
at org.beite.service.impl.ArticleCategoryServiceImpl.listAllCategories(ArticleCategoryServiceImpl.java:27) ~[classes/:na]
at org.beite.service.impl.ArticleCategoryServiceImpl$$FastClassBySpringCGLIB$$f29cc435.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.20.jar:5.3.20]
at org.beite.service.impl.ArticleCategoryServiceImpl$$EnhancerBySpringCGLIB$$648b3ea8.listAllCategories(<generated>) ~[classes/:na]
at org.beite.controller.article.ArticleCategoryController.getAllCategories(ArticleCategoryController.java:29) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) [spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) [spring-webmvc-5.3.20.jar:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) [tomcat-embed-core-9.0.63.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) [spring-webmvc-5.3.20.jar:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [tomcat-embed-core-9.0.63.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.beite.common.filter.AuthorizeAttributeFilter.doFilter(AuthorizeAttributeFilter.java:87) [classes/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.20.jar:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.63.jar:9.0.63]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
是不是没有把rootCause发出来,错误堆栈中没看到fastjson的。没有rootCause的堆栈,不好诊断问题
nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
### Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'】
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
### Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96) ~[mybatis-spring-2.0.6.jar:2.0.6]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.sun.proxy.$Proxy80.selectList(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.sun.proxy.$Proxy86.selectList(Unknown Source) ~[na:na]
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:370) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:379) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
at org.beite.service.impl.ArticleTagsServiceImpl.listTags(ArticleTagsServiceImpl.java:53) ~[classes/:na]
at org.beite.service.impl.ArticleTagsServiceImpl$$FastClassBySpringCGLIB$$a9f6dd3a.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.20.jar:5.3.20]
at org.beite.service.impl.ArticleTagsServiceImpl$$EnhancerBySpringCGLIB$$f7a8bfb.listTags(<generated>) ~[classes/:na]
at org.beite.controller.article.ArticleTagsController.getListTags(ArticleTagsController.java:30) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) [spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) [spring-webmvc-5.3.20.jar:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) [tomcat-embed-core-9.0.63.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) [spring-webmvc-5.3.20.jar:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [tomcat-embed-core-9.0.63.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.beite.common.filter.AuthorizeAttributeFilter.doFilter(AuthorizeAttributeFilter.java:87) [classes/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.20.jar:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.63.jar:9.0.63]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.63.jar:9.0.63]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
### Cause: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.5.6.jar:3.5.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) ~[mybatis-3.5.6.jar:3.5.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) ~[mybatis-3.5.6.jar:3.5.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.6.jar:2.0.6]
... 62 common frames omitted
Caused by: com.alibaba.fastjson2.JSONException: JSON#toJSONString cannot serialize 'MyBatisSQLMonitorPlugin.SqlParamWrapper(param={ew=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946, param1=com.baomidou.mybatisplus.core.toolkit.Wrappers$EmptyWrapper@4de45946})'
at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2339) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at org.beite.common.handler.MyBatisSQLMonitorPlugin.intercept(MyBatisSQLMonitorPlugin.java:81) ~[classes/:na]
at org.beite.common.handler.SQLMonitorPlugin.beforeQuery(SQLMonitorPlugin.java:42) ~[classes/:na]
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:78) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) ~[mybatis-3.5.6.jar:3.5.6]
at com.sun.proxy.$Proxy102.query(Unknown Source) ~[na:na]
at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:132) ~[pagehelper-5.3.0.jar:na]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) ~[mybatis-3.5.6.jar:3.5.6]
at com.sun.proxy.$Proxy102.query(Unknown Source) ~[na:na]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ~[mybatis-3.5.6.jar:3.5.6]
... 68 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.baomidou.mybatisplus.core.conditions.Wrapper.getTargetSql(Wrapper.java:173) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
at com.alibaba.fastjson2.writer.FieldWriterStringFunc.write(FieldWriterStringFunc.java:41) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at com.alibaba.fastjson2.writer.ObjectWriterAdapter.write(ObjectWriterAdapter.java:303) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at com.alibaba.fastjson2.writer.ObjectWriterImplMap.write(ObjectWriterImplMap.java:548) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at com.alibaba.fastjson2.writer.FieldWriterObject.write(FieldWriterObject.java:327) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at com.alibaba.fastjson2.writer.ObjectWriter1.write(ObjectWriter1.java:68) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2334) ~[fastjson2-2.0.30-20230429.115149-8.jar:na]
... 77 common frames omitted
加上JSONWriter.Feature.IgnoreErrorGetter试试看,比如:
JSON.toJSONString(object, JSONWriter.Feature.IgnoreErrorGetter);
全局配置:
JSON.config(JSONWriter.Feature.IgnoreErrorGetter);
或者更新下快照,看下新版本是否会不加也不报错
做了这个处理: https://github.com/alibaba/fastjson2/commit/8fd9d6de2ab7ca504932ab5231237bd0c47dd347
好的
问题已经解决了,不加也可以,使用的快照版本是 fastjson2-2.0.30-20230429.134008-9.jar
问题描述
在我将对象转化为字符串的时候出现了这个问题,我用其他的工具包转化是没有问题的
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
JSON.toJSONString(Object obj)
方法java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/conditions/AbstractWrapper$$Lambda$798/831344888
错误期待的正确结果
成功转化为json字符串
相关日志输出
*java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/core/conditions/AbstractWrapper$$Lambda$798/831344888 at com.alibaba.fastjson2.writer.FieldWriterStringFunc.write(FieldWriterStringFunc.java:41) at com.alibaba.fastjson2.writer.ObjectWriter1.write(ObjectWriter1.java:68) at com.alibaba.fastjson2.writer.ObjectWriterImplList.write(ObjectWriterImplList.java:373) at com.alibaba.fastjson2.writer.OWG_2_5_MergeSegments.write(Unknown Source) at com.alibaba.fastjson2.writer.OWG_1_16_QueryWrapper.write(Unknown Source) at com.alibaba.fastjson2.writer.ObjectWriterImplMap.write(ObjectWriterImplMap.java:548) at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2334) at org.beite.common.handler.MyBatisSQLMonitorPlugin.intercept(MyBatisSQLMonitorPlugin.java:64) at org.beite.common.handler.SQLMonitorPlugin.beforeQuery(SQLMonitorPlugin.java:35) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:78) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy102.query(Unknown Source) at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:132) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy102.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) at com.sun.proxy.$Proxy80.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy86.selectList(Unknown Source) at org.beite.service.impl.ArticleTagsServiceImpl.getTagsNames(ArticleTagsServiceImpl.java:57) at org.beite.service.impl.ArticleTagsServiceImpl$$FastClassBySpringCGLIB$$a9f6dd3a.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386)
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704)
at org.beite.service.impl.ArticleTagsServiceImpl$$EnhancerBySpringCGLIB$$2806e68b.getTagsNames()
at org.beite.service.impl.ArticleServiceImpl.getArticleById(ArticleServiceImpl.java:129)
at org.beite.service.impl.ArticleServiceImpl$$FastClassBySpringCGLIB$$f7fbc213.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386)
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704)
at org.beite.service.impl.ArticleServiceImpl$$EnhancerBySpringCGLIB$$191ae4b6.getArticleById()
at org.beite.controller.article.ArticleController.getArticleById(ArticleController.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.beite.common.filter.AuthorizeAttributeFilter.doFilter(AuthorizeAttributeFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.baomidou.mybatisplus.core.conditions.AbstractWrapper$$Lambda$798.831344888
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 89 more*
附加信息