jd-opensource / sql-analysis

针对大促、日常系统稳定性隐患-慢sql的预防和排查,基于Mybatis插件设计的一款慢sql分析组件,区别于主流的基于慢sql日志分析和预警,实时根据Explain分析结果分析
Apache License 2.0
129 stars 26 forks source link

There is no getter for property named 'delegate' #5

Open ycmingo opened 4 months ago

ycmingo commented 4 months ago

按照集成指引,添加依赖、配置组件 1,依赖

<dependency>
    <groupId>io.github.huht123.sql-analysis</groupId>
    <artifactId>sql-analysis</artifactId>
    <version>1.0</version>
</dependency>

2,配置组件:

@Configuration
public class MyBatisInterceptorConfiguration {
        @Bean
        public Interceptor getSqlAnalysisAspect() {
            SqlAnalysisAspect plugin = new SqlAnalysisAspect();
            Properties properties = new Properties();
            properties.setProperty("analysisSwitch", "true");
            plugin.setProperties(properties);
            return plugin;
        }
  }

执行相应的查询,报如下错误:

2024-04-26 10:59:00.014 ERROR 16 [ Thread-43][] c.j.sql.analysis.core.SqlAnalysisAspect : sql analysis error org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'delegate' in 'class com.sun.proxy.$Proxy615' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:374) at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) at com.jd.sql.analysis.extract.SqlExtract.extract(SqlExtract.java:54) at com.jd.sql.analysis.core.SqlAnalysisAspect.intercept(SqlAnalysisAspect.java:86) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy615.prepare(Unknown Source) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.prepareStatement(MybatisSimpleExecutor.java:94) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:68) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:65) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy614.query(Unknown Source) at sun.reflect.GeneratedMethodAccessor308.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.jd.sql.analysis.core.SqlAnalysisAspect.intercept(SqlAnalysisAspect.java:109) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy614.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.GeneratedMethodAccessor310.invoke(Unknown Source) 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:426) at com.sun.proxy.$Proxy166.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:173) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:78) 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.$Proxy167.queryBySource(Unknown Source) at com.lotus.price.job.ItemPriceInfoJob.removeUnUsedConfig(ItemPriceInfoJob.java:138) at com.lotus.price.job.ItemPriceInfoJob$$FastClassBySpringCGLIB$$9675d7b.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687) at com.lotus.price.job.ItemPriceInfoJob$$EnhancerBySpringCGLIB$$d982df02.removeUnUsedConfig() at sun.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.xxl.job.core.handler.impl.MethodJobHandler.execute(MethodJobHandler.java:31) at com.xxl.job.core.thread.JobThread.run(JobThread.java:163) 2024-04-26 10:59:00.018 ERROR 16 [ Thread-43][] c.j.sql.analysis.core.SqlAnalysisAspect : sql analysis error org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'delegate' in 'class com.sun.proxy.$Proxy615' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:374) at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) at com.jd.sql.analysis.extract.SqlExtract.extract(SqlExtract.java:54) at com.jd.sql.analysis.core.SqlAnalysisAspect.intercept(SqlAnalysisAspect.java:86) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy615.prepare(Unknown Source) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.prepareStatement(MybatisSimpleExecutor.java:94) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:68) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:65) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy614.query(Unknown Source) at sun.reflect.GeneratedMethodAccessor308.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.jd.sql.analysis.core.SqlAnalysisAspect.intercept(SqlAnalysisAspect.java:109) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy614.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.GeneratedMethodAccessor310.invoke(Unknown Source) 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:426) at com.sun.proxy.$Proxy166.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:173) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:78) 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.$Proxy167.selectList(Unknown Source) at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:279) at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:288) at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687) at com.lotus.price.biz.impl.EntityRelationSourceConfigServiceImpl$$EnhancerBySpringCGLIB$$ebe655f6.list() at com.lotus.price.job.ItemPriceInfoJob.removeIds(ItemPriceInfoJob.java:147) at com.lotus.price.job.ItemPriceInfoJob.removeUnUsedConfig(ItemPriceInfoJob.java:139) at com.lotus.price.job.ItemPriceInfoJob$$FastClassBySpringCGLIB$$9675d7b.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687) at com.lotus.price.job.ItemPriceInfoJob$$EnhancerBySpringCGLIB$$d982df02.removeUnUsedConfig() at sun.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.xxl.job.core.handler.impl.MethodJobHandler.execute(MethodJobHandler.java:31) at com.xxl.job.core.thread.JobThread.run(JobThread.java:163)

huht123 commented 4 months ago

是不是使用了其他mybatis组件,调整一下先后顺序

ycmingo commented 4 months ago

是不是使用了其他mybatis组件,调整一下先后顺序

我看了下,配置里面就这么两个

public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); return interceptor; }