HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.36k stars 493 forks source link

Old version mybatis-plus doesn't work #574

Closed Dashu207 closed 2 months ago

Dashu207 commented 2 months ago

is old project:springboot 1.5.4 + mybatis-plus 3.1.1 New Version 1.4.2 (8-19) Project Startup Fails。

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.ClassCastException: org.apache.ibatis.session.Configuration_$$_jvst3920 cannot be cast to com.baomidou.mybatisplus.core.MybatisConfiguration at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1176) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1071) ... 46 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.ClassCastException: org.apache.ibatis.session.Configuration$$_jvst3920 cannot be cast to com.baomidou.mybatisplus.core.MybatisConfiguration at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ... 59 common frames omitted Caused by: java.lang.ClassCastException: org.apache.ibatis.session.Configuration$$_jvst3920 cannot be cast to com.baomidou.mybatisplus.core.MybatisConfiguration at com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder.build(MybatisSqlSessionFactoryBuilder.java:80) at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:611) at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:434) at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.getObject(MybatisSqlSessionFactoryBean.java:633) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:190) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$d2760d59.CGLIB$sqlSessionFactory$2() at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$d2760d59$$FastClassBySpringCGLIB$$a331f449.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$d2760d59.sqlSessionFactory() at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$HOTSWAPAGENT$$FastClassBySpringCGLIB$$1af70b95.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at HotswapSpringCallback_1796692748.intercept(HotswapSpringCallback1796692748.java) at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$HOTSWAPAGENT$$EnhancerBySpringCGLIB$$3f63263c.sqlSessionFactory() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

homejim commented 2 months ago

The code has already been updated, but it hasn't been adapted to version 3.1 yet. I'll build the latest package in a bit, and it should prevent any errors from showing up. However, the dynamic sql might not work.

Dashu207 commented 2 months ago

The code has already been updated, but it hasn't been adapted to version 3.1 yet. I'll build the latest package in a bit, and it should prevent any errors from showing up. However, the dynamic sql might not work.

Thank you for your efforts, this plugin improves everyone's work efficiency.

homejim commented 2 months ago

The code has already been updated, but it hasn't been adapted to version 3.1 yet. I'll build the latest package in a bit, and it should prevent any errors from showing up. However, the dynamic sql might not work.

https://github.com/homejim/HotswapAgent/releases/tag/1.4.2.1-SNAPSHOT

I'm still trying to make versions 3.1 and 3.0 compatible. There have been quite a few changes in the MyBatisPlus code. Maybe you could try upgrading to version 3.2 or later first.

homejim commented 2 months ago

The versions 3.2 to 3.5.7 have been tested.

homejim commented 2 months ago

@skybber If you have time, update to a new 1.4.2 SNAPSHOT version of the AGENT JAR package

Dashu207 commented 2 months ago

The code has already been updated, but it hasn't been adapted to version 3.1 yet. I'll build the latest package in a bit, and it should prevent any errors from showing up. However, the dynamic sql might not work.

https://github.com/homejim/HotswapAgent/releases/tag/1.4.2.1-SNAPSHOT

I'm still trying to make versions 3.1 and 3.0 compatible. There have been quite a few changes in the MyBatisPlus code. Maybe you could try upgrading to version 3.2 or later first.

I've tried to upgrade mybatis-plus to a higher version before, and I need to modify a lot of class references. If it's a new project or a self-testing project, that's fine. But at work, the risk is great, and a bug may appear one day after the system goes live. Anyway, I will try to upgrade to the new version again. Thank you for your positive reply and communication. I hope this plugin will get better and better.

skybber commented 2 months ago

@homejim 1.4.2 SNAPSHOT updated.

skybber commented 2 months ago

done