baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.42k stars 4.31k forks source link

SpringBoot3支持问题 #5527

Closed nieqiurong closed 1 year ago

nieqiurong commented 1 year ago

目前Mybatis-Plus携带的版本为mybatis-spring的版本为2.x,如果需要升级SpringBoot3的话,需要自行将mybatis-spring版本升级至3.x

Native支持: 1.需要升级mybatis版本至3.5.13 2.mybatis-spring升级至3.0.2+ 最好

插件动态代理反射异常: 3.5.3.2修复 #5532

示例工程: https://github.com/nieqiurong/mybatis-native-demo

支持情况: 1.普通增删改查无问题 2.lambda表达式不可使用

另外请关注: https://github.com/mybatis/spring-native

2023年8月20日 感谢 @z744489075 提供lambda处理方式

2023年9月18日 新增mybatis-plus-spring-boot3-starter对SpringBoot3支持.

目前支持情况:

  1. 新增了枚举示例加入
  2. 新增了crud一些api操作
  3. 新增填充示例 与SpringBoot3支持模块(2023-10-12) 截图_滚动截图_20231012030422
ccwxl commented 1 year ago

lambda的问题可以看看这个 https://github.com/quarkiverse/quarkus-mybatis/issues/184

Coolkids commented 1 year ago

你好 请问测试了内置分页插件么?我按照给的例子,使用内置分页插件后,启动后执行分页查询会出现各种NoSuchMethodException

Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer)

nieqiurong commented 1 year ago

lambda的问题可以看看这个 quarkiverse/quarkus-mybatis#184

可能要等spring-native了,目前不是很好解决。

nieqiurong commented 1 year ago

你好 请问测试了内置分页插件么?我按照给的例子,使用内置分页插件后,启动后执行分页查询会出现各种NoSuchMethodException

Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer)

异常提供详细点吧,明明天有空我看看分页的。

Coolkids commented 1 year ago

你好 请问测试了内置分页插件么?我按照给的例子,使用内置分页插件后,启动后执行分页查询会出现各种NoSuchMethodException Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer)

异常提供详细点吧,明明天有空我看看分页的。

2023-08-03 00:33:05.650 === [main]=== INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat] 2023-08-03 00:33:05.655 === [main]=== ERROR org.springframework.boot.SpringApplication - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rssUpdateQueueJob': ### Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) ### Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) at com.coolkid.coolkidrss.CoolkidRssApplication.main(CoolkidRssApplication.java:20) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) ### Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:101) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:57) at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:110) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:422) at jdk.proxy4/jdk.proxy4.$Proxy285.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 jdk.proxy4/jdk.proxy4.$Proxy52.selectList(Unknown Source) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1869) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1826) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ... 16 common frames omitted Caused by: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:82) at org.apache.ibatis.plugin.Plugin.wrap(Plugin.java:45) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.plugin(MybatisPlusInterceptor.java:112) at org.apache.ibatis.plugin.InterceptorChain.pluginAll(InterceptorChain.java:31) at org.apache.ibatis.session.Configuration.newExecutor(Configuration.java:736) at com.baomidou.mybatisplus.core.MybatisConfiguration.newExecutor(MybatisConfiguration.java:366) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:97) ... 45 common frames omitted Caused by: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at java.base@17.0.6/java.lang.Class.getMethod(DynamicHub.java:2227) at org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:79) ... 51 common frames omitted

wssy001 commented 1 year ago

@Coolkids 分页插件有个简单的解决法子,提示什么接口找不到,就添加相应接口到proxy-config.json中;提示什么类找不到,就添加到reflect-config.json 我用这种方法测试了分页插件和乐观锁插件,基础的CRUD测试通过

Coolkids commented 1 year ago

@Coolkids 分页插件有个简单的解决法子,提示什么接口找不到,就添加相应接口到proxy-config.json中;提示什么类找不到,就添加到reflect-config.json 我用这种方法测试了分页插件和乐观锁插件,基础的CRUD测试通过

可以发下你测试的reflect-config.json和proxy-config.json配置文件么, 我按照这种方式最后报错 Proxy class defined by interfaces [interface org.apache.ibatis.executor.Executor] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles=<comma-separated-config-files> and -H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.

nieqiurong commented 1 year ago

你好 请问测试了内置分页插件么?我按照给的例子,使用内置分页插件后,启动后执行分页查询会出现各种NoSuchMethodException Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer)

异常提供详细点吧,明明天有空我看看分页的。

2023-08-03 00:33:05.650 === [main]=== INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat] 2023-08-03 00:33:05.655 === [main]=== ERROR org.springframework.boot.SpringApplication - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rssUpdateQueueJob': ### Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) ### Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) at com.coolkid.coolkidrss.CoolkidRssApplication.main(CoolkidRssApplication.java:20) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error opening session. Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) ### Cause: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:101) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:57) at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:110) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:422) at jdk.proxy4/jdk.proxy4.$Proxy285.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 jdk.proxy4/jdk.proxy4.$Proxy52.selectList(Unknown Source) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1869) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1826) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ... 16 common frames omitted Caused by: org.apache.ibatis.plugin.PluginException: Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:82) at org.apache.ibatis.plugin.Plugin.wrap(Plugin.java:45) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.plugin(MybatisPlusInterceptor.java:112) at org.apache.ibatis.plugin.InterceptorChain.pluginAll(InterceptorChain.java:31) at org.apache.ibatis.session.Configuration.newExecutor(Configuration.java:736) at com.baomidou.mybatisplus.core.MybatisConfiguration.newExecutor(MybatisConfiguration.java:366) at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:97) ... 45 common frames omitted Caused by: java.lang.NoSuchMethodException: org.apache.ibatis.executor.statement.StatementHandler.prepare(java.sql.Connection, java.lang.Integer) at java.base@17.0.6/java.lang.Class.getMethod(DynamicHub.java:2227) at org.apache.ibatis.plugin.Plugin.getSignatureMap(Plugin.java:79) ... 51 common frames omitted

示例工程更新了. image

nieqiurong commented 1 year ago

image

Coolkids commented 1 year ago

image

经过测试,分页问题解决了. 多谢

jptx1234 commented 1 year ago

请问Mybatis-Plus是否有计划从某个版本开始默认携带3.x版本的mybatis-spring?

如果没有的话,我贡献几个思路:

  1. 在Mybatis-Plus 4.x大版本;
  2. 等Spring Boot 2.x版本停止社区支持(2023-11-18)
  3. 等mybatis-spring 2.x版本停止维护(暂未找到官方预计停止维护时间)

我看到 commit https://github.com/baomidou/mybatis-plus/commit/be7a90fdbf54b99fa3f8ceb6c75ef3d99fe4f8f6 中把mybati-spring版本又降回了2.x版本,是在为未来升级做准备了吗?

nieqiurong commented 1 year ago

请问Mybatis-Plus是否有计划从某个版本开始默认携带3.x版本的mybatis-spring?

如果没有的话,我贡献几个思路:

  1. 在Mybatis-Plus 4.x大版本;
  2. 等Spring Boot 2.x版本停止社区支持(2023-11-18)
  3. 等mybatis-spring 2.x版本停止维护(暂未找到官方预计停止维护时间)

我看到 commit be7a90f 中把mybati-spring版本又降回了2.x版本,是在为未来升级做准备了吗?

mybatis-plus 4.x大概率跟着mybatis4.x走,mybatis-plus3.x的维护随着mybatis3.x版本走,但3.x的版本还是要维护好java8和高版本的jdk支持,可能后面发两个版本的starter把.

SimonVonXCVII commented 1 year ago

Linux(debian 11.7) 环境使用 graalvm(build 17.0.8+9-LTS-jvmci-23.0-b14) 打包(gradle nativeCompile) spring boot 3.1.2 + mybatis plus 3.5.3.3-SNAPSHOT 原生镜像文件成功,但是运行报错:Caused by: java.lang.NoSuchMethodException: com.baomidou.mybatisplus.core.handlers.CompositeEnumTypeHandler.()。请问如何解决 微信图片_20230810112823

nieqiurong commented 1 year ago

Linux(debian 11.7) 环境使用 graalvm(build 17.0.8+9-LTS-jvmci-23.0-b14) 打包(gradle nativeCompile) spring boot 3.1.2 + mybatis plus 3.5.3.3-SNAPSHOT 原生镜像文件成功,但是运行报错:Caused by: java.lang.NoSuchMethodException: com.baomidou.mybatisplus.core.handlers.CompositeEnumTypeHandler.()。请问如何解决 微信图片_20230810112823

试试 hints.reflection().registerType(CompositeEnumTypeHandler.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);

lichong-a commented 1 year ago
nieqiurong commented 1 year ago
  • 环境 jdk17 springboot3.0.8 mybatis-plus3.5.3.2 mybatis-spring-boot-starter3.0.2
  • 问题 native打包后启动报错如下,请问目前有适配方案吗?
2023-08-14 16:34:02.023 [main] ERROR o.s.boot.SpringApplication.reportFailure-822 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigController': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608)
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
  at com.eoi.web.LogInspectApplication.main(LogInspectApplication.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 21 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167)
  at com.eoi.core.manager.impl.LogInspectTaskConfigManagerImpl__Autowiring.apply(LogInspectTaskConfigManagerImpl__Autowiring.java:15)
  at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:83)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 38 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189)
  ... 56 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.util.Assert.notNull(Assert.java:204)
  at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:125)
  at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
  at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
  ... 66 common frames omitted

这些错误信息看不出具体问题,请提供一个工程示例过来看看,目前示例工程也没碰到这种错误.

lichong-a commented 1 year ago
  • 环境 jdk17 springboot3.0.8 mybatis-plus3.5.3.2 mybatis-spring-boot-starter3.0.2
  • 问题 native预算后启动报错如下,请问目前有装备方案吗?
2023-08-14 16:34:02.023 [main] ERROR o.s.boot.SpringApplication.reportFailure-822 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigController': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
    at com.eoi.web.LogInspectApplication.main(LogInspectApplication.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
    at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
    ... 21 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195)
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167)
    at com.eoi.core.manager.impl.LogInspectTaskConfigManagerImpl__Autowiring.apply(LogInspectTaskConfigManagerImpl__Autowiring.java:15)
    at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:83)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
    at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
    at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
    ... 38 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189)
    ... 56 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    at org.springframework.util.Assert.notNull(Assert.java:204)
    at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:125)
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
    ... 66 common frames omitted

这些错误信息看不出具体问题,请提供一个工程示例过来看看,目前工程示例并未提及此类错误。

工程示例请查看:https://github.com/lichong-a/mybatis-plus-native.git

z744489075 commented 1 year ago
  • 环境 jdk17 springboot3.0.8 mybatis-plus3.5.3.2 mybatis-spring-boot-starter3.0.2
  • 问题 本机预算启动后报错如下,请问目前有装备方案吗?
2023-08-14 16:34:02.023 [main] ERROR o.s.boot.SpringApplication.reportFailure-822 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigController': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608)
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
  at com.eoi.web.LogInspectApplication.main(LogInspectApplication.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 21 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167)
  at com.eoi.core.manager.impl.LogInspectTaskConfigManagerImpl__Autowiring.apply(LogInspectTaskConfigManagerImpl__Autowiring.java:15)
  at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:83)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 38 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189)
  ... 56 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.util.Assert.notNull(Assert.java:204)
  at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:125)
  at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
  at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
  ... 66 common frames omitted

这些错误信息看不出具体问题,请提供一个工程示例过来看看,目前工程示例暗示此类错误。

工程示例请查看:https://github.com/lichong-a/mybatis-plus-native.git

AOT 不支持 @MapperScan({"work.lichong.test"}) 在mapper层 用 @Mapper 注入

z744489075 commented 1 year ago

@nieqiurong 请问这个lambda有思路了吗? 我来改把试试.

nieqiurong commented 1 year ago
  • 环境 jdk17 springboot3.0.8 mybatis-plus3.5.3.2 mybatis-spring-boot-starter3.0.2
  • 问题 native预算后启动报错如下,请问目前有装备方案吗?
2023-08-14 16:34:02.023 [main] ERROR o.s.boot.SpringApplication.reportFailure-822 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigController': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608)
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
  at com.eoi.web.LogInspectApplication.main(LogInspectApplication.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigService': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:315)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:258)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:198)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 21 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logInspectTaskConfigManagerImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167)
  at com.eoi.core.manager.impl.LogInspectTaskConfigManagerImpl__Autowiring.apply(LogInspectTaskConfigManagerImpl__Autowiring.java:15)
  at org.springframework.beans.factory.support.InstanceSupplier$1.get(InstanceSupplier.java:83)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888)
  at org.springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:228)
  at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:312)
  ... 38 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logInspectTaskConfigMapper': Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337)
  at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189)
  ... 56 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.util.Assert.notNull(Assert.java:204)
  at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:125)
  at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
  at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
  ... 66 common frames omitted

这些错误信息看不出具体问题,请提供一个工程示例过来看看,目前工程示例并未提及此类错误。

工程示例请查看:https://github.com/lichong-a/mybatis-plus-native.git

https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start-for-building-native-image image

nieqiurong commented 1 year ago

@nieqiurong 请问这个lambda有思路了吗? 我来改把试试.

没有,没怎么花时间弄这个,你弄好了可以提交PR上来.

z744489075 commented 1 year ago

@nieqiurong 请问这个lambda有思路了吗? 我来改把试试.

没有,没怎么花时间弄这个,你弄好了可以提交PR上来.

https://github.com/baomidou/mybatis-plus/pull/5594 我测试是OK了. spring-native 就别想了.那位老哥说这个东西不常用所以不做. 我基于graal Feature 做了个自定义注解来适配

nieqiurong commented 1 year ago

@nieqiurong 请问这个lambda有思路了吗? 我来改把试试.

没有,没怎么花时间弄这个,你弄好了可以提交PR上来.

5594 我测试是OK了. spring-native 就别想了.那位老哥说这个东西不常用所以不做. 我基于graal Feature 做了个自定义注解来适配

方案可行,先在示例中增加上你这个方式.

wssy001 commented 1 year ago

5594 反复确认了一下 这个PR提交前,IService的几个方法是可以处理Wrappers.<ClassInfo>lambdaQuery()构造的Wrapper

但是链式调用Lambda一直不行
示例项目可以补一个 链式调用 lambda 式 的例子 这样更能说明这个PR带来的效果

sk142857 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

z744489075 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

sk142857 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

感谢!还有个问题请教下,就是加载 mapper 文件。AOT模式下,90个mapper文件,应用启动耗时非常长,我们测试的时候竟然要100多秒。

2023-08-28 11:37:31.940 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@46e4d2bf5 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:33.314 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@2f0786be22 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:33 GMT}{Via: 1.1 varnish}{Age: 590}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 637}{X-Timer: S1693193853.194031,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 05667510ef4f552f60709a8ec374862e7166a878}
2023-08-28 11:37:34.078 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@6688ef285 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:34.903 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@27529bf622 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:34 GMT}{Via: 1.1 varnish}{Age: 591}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 640}{X-Timer: S1693193855.785410,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 28905d1c3954844d24be7e39aed5fba09c7ef910}
z744489075 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

感谢!还有个问题请教下,就是加载 mapper 文件。AOT模式下,90个mapper文件,应用启动耗时非常长,我们测试的时候竟然要100多秒。

2023-08-28 11:37:31.940 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@46e4d2bf5 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:33.314 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@2f0786be22 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:33 GMT}{Via: 1.1 varnish}{Age: 590}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 637}{X-Timer: S1693193853.194031,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 05667510ef4f552f60709a8ec374862e7166a878}
2023-08-28 11:37:34.078 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@6688ef285 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:34.903 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@27529bf622 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:34 GMT}{Via: 1.1 varnish}{Age: 591}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 640}{X-Timer: S1693193855.785410,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 28905d1c3954844d24be7e39aed5fba09c7ef910}

看demo

Stream.of( "org/apache/ibatis/builder/xml/..dtd", "org/apache/ibatis/builder/xml/..xsd", "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧本地的资源文件加载进去就好. 另外你可以COPY demo里面的 MyBatisNativeConfiguration 在这个基础上改.

sk142857 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

感谢!还有个问题请教下,就是加载 mapper 文件。AOT模式下,90个mapper文件,应用启动耗时非常长,我们测试的时候竟然要100多秒。

2023-08-28 11:37:31.940 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@46e4d2bf5 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:33.314 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@2f0786be22 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:33 GMT}{Via: 1.1 varnish}{Age: 590}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 637}{X-Timer: S1693193853.194031,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 05667510ef4f552f60709a8ec374862e7166a878}
2023-08-28 11:37:34.078 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@6688ef285 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:34.903 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@27529bf622 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:34 GMT}{Via: 1.1 varnish}{Age: 591}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 640}{X-Timer: S1693193855.785410,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 28905d1c3954844d24be7e39aed5fba09c7ef910}

看demo

Stream.of( "org/apache/ibatis/builder/xml/..dtd", "org/apache/ibatis/builder/xml/..xsd", "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧本地的资源文件加载进去就好. 另外你可以COPY demo里面的 MyBatisNativeConfiguration 在这个基础上改.

这个我看过,我用的也是demo中的MyBatisNativeConfiguration。但是,似乎DTD文件,应用在启动的时候,会从mybatis.org网站下载dtd文件,导致加载mapper非常慢,并没有从本地加载。

是否跟这个参数 javax.xml.accessExternalDTD 有关?按照官方的例子,AOT模式下需要设置javax.xml.accessExternalDTD=all,这样导致从mybatis.org下载dtd文件?90个mapper文件,下载90次?

如果不设置的话,启动就报错,提示Invalid bound statement (not found)

z744489075 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

感谢!还有个问题请教下,就是加载 mapper 文件。AOT模式下,90个mapper文件,应用启动耗时非常长,我们测试的时候竟然要100多秒。

2023-08-28 11:37:31.940 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@46e4d2bf5 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:33.314 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@2f0786be22 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:33 GMT}{Via: 1.1 varnish}{Age: 590}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 637}{X-Timer: S1693193853.194031,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 05667510ef4f552f60709a8ec374862e7166a878}
2023-08-28 11:37:34.078 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@6688ef285 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:34.903 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@27529bf622 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:34 GMT}{Via: 1.1 varnish}{Age: 591}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 640}{X-Timer: S1693193855.785410,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 28905d1c3954844d24be7e39aed5fba09c7ef910}

看demo Stream.of( "org/apache/ibatis/builder/xml/..dtd", "org/apache/ibatis/builder/xml/..xsd", "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧本地的资源文件加载进去就好. 另外你可以COPY demo里面的 MyBatisNativeConfiguration 在这个基础上改.

这个我看过,我用的也是demo中的MyBatisNativeConfiguration。但是,似乎DTD文件,应用在启动的时候,会从mybatis.org网站下载dtd文件,导致加载mapper非常慢,并没有从本地加载。

是否跟这个参数 javax.xml.accessExternalDTD 有关?按照官方的例子,AOT模式下需要设置javax.xml.accessExternalDTD=all,这样导致从mybatis.org下载dtd文件?90个mapper文件,下载90次?

如果不设置的话,启动就报错,提示Invalid bound statement (not found)

javax.xml.accessExternalDTD 这个是mybatis说的? 不用设置的. 我这边没有设置哦. 只要使用这个issues提供的 MyBatisNativeConfiguration 里面加上你自己的 Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 就好. 我这边 136个mapper 文件启动要7秒. 比一般都AOT项目要长4秒左右. 但是也没你这个 100多秒...

sk142857 commented 1 year ago

mapper-locations 这个配置 AOT 模式下好像不支持,有别的办法吗?目前,在AOT模式下使用相同的Package是可以运行成功的。

Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧资源文件注入进去就好了. 在 RuntimeHintsRegistrar 中加个注入就行

感谢!还有个问题请教下,就是加载 mapper 文件。AOT模式下,90个mapper文件,应用启动耗时非常长,我们测试的时候竟然要100多秒。

2023-08-28 11:37:31.940 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@46e4d2bf5 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:33.314 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@2f0786be22 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:33 GMT}{Via: 1.1 varnish}{Age: 590}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 637}{X-Timer: S1693193853.194031,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 05667510ef4f552f60709a8ec374862e7166a878}
2023-08-28 11:37:34.078 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@6688ef285 pairs: {GET /dtd/mybatis-3-mapper.dtd HTTP/1.1: null}{User-Agent: Java/17.0.7}{Host: mybatis.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
2023-08-28 11:37:34.903 | DEBUG [] main | sun.net.www.protocol.http.HttpURLConnection | sun.net.www.MessageHeader@27529bf622 pairs: {null: HTTP/1.1 200 OK}{Connection: keep-alive}{Content-Length: 7458}{Server: GitHub.com}{Content-Type: application/xml-dtd}{Last-Modified: Wed, 07 Sep 2022 23:28:43 GMT}{Access-Control-Allow-Origin: *}{ETag: "6319292b-1d22"}{expires: Tue, 22 Aug 2023 22:28:33 GMT}{Cache-Control: max-age=600}{x-proxy-cache: MISS}{X-GitHub-Request-Id: AA4C:0397:901881:97E565:64E53439}{Accept-Ranges: bytes}{Date: Mon, 28 Aug 2023 03:37:34 GMT}{Via: 1.1 varnish}{Age: 591}{X-Served-By: cache-nrt-rjtf7700031-NRT}{X-Cache: HIT}{X-Cache-Hits: 640}{X-Timer: S1693193855.785410,VS0,VE0}{Vary: Accept-Encoding}{X-Fastly-Request-ID: 28905d1c3954844d24be7e39aed5fba09c7ef910}

看demo Stream.of( "org/apache/ibatis/builder/xml/..dtd", "org/apache/ibatis/builder/xml/..xsd", "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 吧本地的资源文件加载进去就好. 另外你可以COPY demo里面的 MyBatisNativeConfiguration 在这个基础上改.

这个我看过,我用的也是demo中的MyBatisNativeConfiguration。但是,似乎DTD文件,应用在启动的时候,会从mybatis.org网站下载dtd文件,导致加载mapper非常慢,并没有从本地加载。 是否跟这个参数 javax.xml.accessExternalDTD 有关?按照官方的例子,AOT模式下需要设置javax.xml.accessExternalDTD=all,这样导致从mybatis.org下载dtd文件?90个mapper文件,下载90次? 如果不设置的话,启动就报错,提示Invalid bound statement (not found)

javax.xml.accessExternalDTD 这个是mybatis说的? 不用设置的. 我这边没有设置哦. 只要使用这个issues提供的 MyBatisNativeConfiguration 里面加上你自己的 Stream.of( "mybatisXml/*Dao.xml" ).forEach(hints.resources()::registerPattern); 就好. 我这边 136个mapper 文件启动要7秒. 比一般都AOT项目要长4秒左右. 但是也没你这个 100多秒...

确实是有问题的,加载mapper,每次都会从 mybatis.org 网站下载 DTD 文件。不过这个问题好像已经修复了,你看看https://github.com/mybatis/spring-boot-starter/issues/852

现在项目启动正常了。

ty123000 commented 1 year ago

maven中央仓库没有看到有mybatis-plus-spring-boot3-starter,在哪能获取到这个依赖啊?

nieqiurong commented 1 year ago

maven中央仓库没有看到有mybatis-plus-spring-boot3-starter,在哪能获取到这个依赖啊?

快照版,正式版本没发布. https://oss.sonatype.org/content/repositories/snapshots/com/baomidou/mybatis-plus-spring-boot3-starter/3.5.4-SNAPSHOT/

nieqiurong commented 1 year ago
  • 环境 jdk17 springboot3.1.4 mybatis-plus3.5.3.2 mybatis-spring-boot-starter3.0.2
  • 问题 项目native-image后启动,查询和删除可以使用,修改和新增报错,代码中MybatisMetaObjectHandler实现MetaObjectHandler针对insert和update做了属性公共填充。报错如下: ps:去掉属性填充可正常使用,这部分有什么解决方案吗?

`org.mybatis.spring.MyBatisSystemException: null at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) at jdk.proxy4/jdk.proxy4.$Proxy109.update(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:64) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at jdk.proxy4/jdk.proxy4.$Proxy78.updateById(Unknown Source) at cn.xxx.base.BaseService.updateEntityById(BaseService.java:36) at com.xxx.sys.user.service.impl.RoleServiceImpl.update(RoleServiceImpl.java:188) at java.base@17.0.8/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:391) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703) at com.xxx.sys.user.service.impl.RoleServiceImpl$$SpringCGLIB$$0.update() at com.xxx.sys.user.controller.RoleController.update(RoleController.java:99) at java.base@17.0.8/java.lang.reflect.Method.invoke(Method.java:568) 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:118) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:925) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:593) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:289) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) 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.base@17.0.8/java.lang.Thread.run(Thread.java:833) at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:807) at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:210) Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: java.lang.NullPointerException

The error may exist in com/xxx/sys/user/mapper/RoleMapper.java (best guess)

The error may involve com.xxx.sys.user.mapper.RoleMapper.updateById

The error occurred while executing an update

Cause: java.lang.NullPointerException

    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
    at java.base@17.0.8/java.lang.reflect.Method.invoke(Method.java:568)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
    ... 89 common frames omitted

Caused by: java.lang.NullPointerException: null at cn.xxx.MybatisMetaObjectHandler.updateFill(MybatisMetaObjectHandler.java:30) at com.baomidou.mybatisplus.core.MybatisParameterHandler.lambda$updateFill$1(MybatisParameterHandler.java:172) at java.base@17.0.8/java.util.Optional.ifPresent(Optional.java:178) at com.baomidou.mybatisplus.core.MybatisParameterHandler.updateFill(MybatisParameterHandler.java:170) at com.baomidou.mybatisplus.core.MybatisParameterHandler.process(MybatisParameterHandler.java:117) at java.base@17.0.8/java.util.ArrayList.forEach(ArrayList.java:1511) at com.baomidou.mybatisplus.core.MybatisParameterHandler.processParameter(MybatisParameterHandler.java:83) at com.baomidou.mybatisplus.core.MybatisParameterHandler.(MybatisParameterHandler.java:72) at com.baomidou.mybatisplus.core.MybatisXMLLanguageDriver.createParameterHandler(MybatisXMLLanguageDriver.java:46) at org.apache.ibatis.session.Configuration.newParameterHandler(Configuration.java:700) at org.apache.ibatis.executor.statement.BaseStatementHandler.(BaseStatementHandler.java:70) at org.apache.ibatis.executor.statement.PreparedStatementHandler.(PreparedStatementHandler.java:42) at org.apache.ibatis.executor.statement.RoutingStatementHandler.(RoutingStatementHandler.java:47) at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:714) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) at java.base@17.0.8/java.lang.reflect.Method.invoke(Method.java:568) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59) at jdk.proxy4/jdk.proxy4.$Proxy98.update(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ... 91 common frames omitted `

看看MybatisMetaObjectHandler.java:30写的什么,或者你先下载示例工程运行一次。 截图_滚动截图_20231012031707 截图_滚动截图_20231012030422

insist-learning commented 1 year ago

尝试在老项目集成了 graalvm,总结下

  1. 首先要升级 mybatis 的版本到 3.5.13,否则会报错,具体看该 issues https://github.com/mybatis/mybatis-3/issues/2858

  2. 拷贝上面大大添加的配置 https://github.com/nieqiurong/mybatis-native-demo/blob/mybatis-plus/src/main/java/com/example/nativedemo/MyBatisNativeConfiguration.java 在此基础上还有的类需要注册反射 LanguageDriver.class ,MybatisXMLLanguageDriver.class, PageHelper.class 以及如果有自定义日志类什么的都要注册,总之就是通过反射实例化的都要注册

  3. 然后遇到了 sqlSessionTemplate 无法注入的问题,在 mybatis 上是能自动注入进来的这边就不行,对比了 MybatisAutoConfiguration 和 MybatisPlusAutoConfiguration ,没有发现差异太大的逻辑,实在找不到解决办法,就暴力添加 ,就是通过后置后置处理器直接给所有 mapper 的工厂 bean 赋值 sqlSessionTemplate image

  4. 循环依赖问题,改成懒加载

5.关于 lambda 的支持,https://github.com/spring-projects/spring-framework/issues/29655 1)添加 sdk

 <dependency>
        <groupId>org.graalvm.sdk</groupId>
        <artifactId>graal-sdk</artifactId>
        <version>23.0.0</version>
    </dependency>

2)注册 lambdaCapturingClass

public class LambdaRegistrationFeature implements Feature {
    @Override
    public void duringSetup(DuringSetupAccess access) {
        // TODO 这里需要将lambda表达式所使用的成员类都注册上来,具体情况视项目情况而定,一般扫描@Controller和@Service的会多点.
        RuntimeSerialization.registerLambdaCapturingClass(ProductServiceImpl.class);
    }
}

3)给 native-image 添加参数 --features=com.fangzhou.aot.LambdaRegistrationFeature 4) 遇到了 sdk 不兼容问题,如下错误 sdk/23.0.0/graal-sdk-23.0.0.jar contains class com.oracle.svm.core.annotate.TargetElement. This class is part of the image builder itself (in jrt:/org.graalvm.sdk) and must not be passed 无解决办法,选择按照提示加参数忽略

-H:+AllowDeprecatedBuilderClassesOnImageClasspath

5)最终配置如下 image

ideaviewes commented 1 year ago

所以现在是什么情况,完全支持了吗?

yuanluochenfeng commented 11 months ago

尝试在老项目集成了 graalvm,总结下

  1. 首先要升级 mybatis 的版本到 3.5.13,否则会报错,具体看该 issues Please compile the project with parameters information (-parameters) mybatis/mybatis-3#2858
  2. 拷贝上面大大添加的配置 https://github.com/nieqiurong/mybatis-native-demo/blob/mybatis-plus/src/main/java/com/example/nativedemo/MyBatisNativeConfiguration.java 在此基础上还有的类需要注册反射 LanguageDriver.class ,MybatisXMLLanguageDriver.class, PageHelper.class 以及如果有自定义日志类什么的都要注册,总之就是通过反射实例化的都要注册
  3. 然后遇到了 sqlSessionTemplate 无法注入的问题,在 mybatis 上是能自动注入进来的这边就不行,对比了 MybatisAutoConfiguration 和 MybatisPlusAutoConfiguration ,没有发现差异太大的逻辑,实在找不到解决办法,就暴力添加 ,就是通过后置后置处理器直接给所有 mapper 的工厂 bean 赋值 sqlSessionTemplate image
  4. 循环依赖问题,改成懒加载

5.关于 lambda 的支持,spring-projects/spring-framework#29655 1)添加 sdk

 <dependency>
        <groupId>org.graalvm.sdk</groupId>
        <artifactId>graal-sdk</artifactId>
        <version>23.0.0</version>
    </dependency>

2)注册 lambdaCapturingClass

public class LambdaRegistrationFeature implements Feature {
    @Override
    public void duringSetup(DuringSetupAccess access) {
        // TODO 这里需要将lambda表达式所使用的成员类都注册上来,具体情况视项目情况而定,一般扫描@Controller和@Service的会多点.
        RuntimeSerialization.registerLambdaCapturingClass(ProductServiceImpl.class);
    }
}

3)给 native-image 添加参数 --features=com.fangzhou.aot.LambdaRegistrationFeature 4) 遇到了 sdk 不兼容问题,如下错误 sdk/23.0.0/graal-sdk-23.0.0.jar contains class com.oracle.svm.core.annotate.TargetElement. This class is part of the image builder itself (in jrt:/org.graalvm.sdk) and must not be passed 无解决办法,选择按照提示加参数忽略 -H:+AllowDeprecatedBuilderClassesOnImageClasspath 5)最终配置如下 image

我这边也在老项目中进行了native image , 但是我这边有元数据收集这一步骤(反射、代理等)。并且native image打包后,文件大小比普通的jar要大了接近1倍的大小。不知道你那边是否也有同样的问题?

Canon-create commented 6 months ago

所以现在是什么情况,完全支持了吗?

好像是支持了,我把依赖改成下面这个就跑通了


            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
            <version>3.5.5</version>
        </dependency>