baomidou / mybatis-plus

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

Spring Boot 3.2.0 啥时候做适配呢 #5808

Closed zhp941024 closed 10 months ago

zhp941024 commented 10 months ago

报错信息

Exception encountered during context initialization - cancelling refresh attempt: java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
C20171008S commented 10 months ago

太慢了。mybatis官方,我观察了两次,基本在Spring大版本出来24小时之内出新版本适配,在RC时候都在适配,所以速度快,lombok也是非常快。作为基础框架国产的有个通用缺点就是RC时期不适配,等到Spring大版本出来需要等待1周(较快),1-n个月才出来适配,而且适配很不到位,比如JDK21出来后Dubbo到现在都不支持虚拟线程。

pigeon2049 commented 10 months ago

等3.5.5正式版 等不及的话现在可以启用snapshot库

  <dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
      <version>3.5.5-SNAPSHOT</version>
  </dependency>
C20171008S commented 10 months ago

等3.5.5正式版 等不及的话现在可以启用snapshot库

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

还要改maven仓库,比较麻烦,再等等。

coffee-developer commented 10 months ago
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.5.4.1</version>
  <exclusions>
      <exclusion>
          <artifactId>mybatis-spring</artifactId>
          <groupId>org.mybatis</groupId>
      </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis-spring</artifactId>
  <version>3.0.3</version>
</dependency>

手动升级mybaits-spring就可以正常使用了

XuYaoAnansi commented 10 months ago
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.5.4.1</version>
  <exclusions>
      <exclusion>
          <artifactId>mybatis-spring</artifactId>
          <groupId>org.mybatis</groupId>
      </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis-spring</artifactId>
  <version>3.0.3</version>
</dependency>

手动升级mybaits-spring就可以正常使用了

这种方式会在编译Spring-Native镜像文件的时候,运行期间产生“Parameter 0 of constructor in org.mybatis.spring.mapper.MapperFactoryBean required a bean of type 'java.lang.Class' that could not be found.”这个错误,你们有遇到吗?

nieqiurong commented 10 months ago

5747

dingshaohua-com commented 10 months ago

我昨天已经搞定了

springBoot: 3.2
java: v21
mybatis: v3.2.4.1
swagger: v3

这里是完整笔记:https://www.cnblogs.com/dingshaohua/p/17861736.html

其中 摘取核心部分 可以针对你的问题: 启动项目,发现依然报错Invalid value type for attribute 'factoryBeanObjectType': java.lang.String

最终定位是 springBoot不兼容MyBatis v2.1.1所致,我跟踪了半天 发现是因为MyBatis Plus(mybatis-plus-boot-starter)里依赖了MyBatis v2.1.1,于是再pom文件指定MyBatis高版本即可。

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>LATEST</version>
</dependency>

再次启动,就成功啦

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.0)

[main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 21.0.1 with PID 10068 (demo\target\classes started by Administrator in IdeaProjects\demo)
[main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
[main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
[main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
[main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.16]
[main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
[main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 555 ms
 _ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ 
     /               |         
                        3.5.4.1 
[main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
[main] com.example.demo.DemoApplication         : Started DemoApplication in 1.266 seconds 
h03x03 commented 10 months ago
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.5.4.1</version>
  <exclusions>
      <exclusion>
          <artifactId>mybatis-spring</artifactId>
          <groupId>org.mybatis</groupId>
      </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis-spring</artifactId>
  <version>3.0.3</version>
</dependency>

手动升级mybaits-spring就可以正常使用了

这种方式会在编译Spring-Native镜像文件的时候,运行期间产生“org.mybatis.spring.mapper.MapperFactoryBean中的构造函数的参数0需要一个类型为'java.lang.Class'的bean,但找不到。 “这个错误,你们遇到了吗?

您好,请问解决了吗?

nieqiurong commented 10 months ago

已发布3.5.5-SNAPSHOT

XuYaoAnansi commented 10 months ago
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.5.4.1</version>
  <exclusions>
      <exclusion>
          <artifactId>mybatis-spring</artifactId>
          <groupId>org.mybatis</groupId>
      </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis-spring</artifactId>
  <version>3.0.3</version>
</dependency>

手动升级mybaits-spring就可以正常使用了

这种方式会在编译Spring-Native镜像文件的时候,运行期间产生“org.mybatis.spring.mapper.MapperFactoryBean中的构造函数的参数0需要一个类型为'java.lang.Class'的bean,但找不到。 “这个错误,你们遇到了吗?

您好,请问解决了吗?

没,等待3.5.5正式发布了测试

ZhiQinIsZhen commented 10 months ago

正式版给我冲