spring boot 集成 flowable + mybatisplus冲突解决

开发项目使用技术栈spring boot 2 + mybatis-plus + flowable 6.3时, 启动报错,如下:

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

  com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:384)

The following method did not exist:

  org.apache.ibatis.session.Configuration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver;

The calling method's class, com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder, was loaded from the following location:

    jar:file:/D:/maven/repository/com/baomidou/mybatis-plus-core/3.4.3.4/mybatis-plus-core-3.4.3.4.jar!/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.class

The called method's class, org.apache.ibatis.session.Configuration, is available from the following locations:

    jar:file:/D:/maven/repository/org/mybatis/mybatis/3.4.5/mybatis-3.4.5.jar!/org/apache/ibatis/session/Configuration.class

The called method's class hierarchy was loaded from the following locations:

    org.apache.ibatis.session.Configuration: file:/D:/maven/repository/org/mybatis/mybatis/3.4.5/mybatis-3.4.5.jar
Action:

Correct the classpath of your application so that it contains compatible versions of the classes com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder and org.apache.ibatis.session.Configuration

仔细查看问题描述,一直没搞懂mybatis 怎么引入的,后来才发现flowable是也会引入 mybatis,导致jar冲突。

找到问题所在,解决起来就简单了:

在pom.xml 中,引入 flowable  时,排除 mybatis 的部分即可。

<dependency>
   <groupId>org.flowable</groupId>
   <artifactId>flowable-spring-boot-starter</artifactId>
   <version>6.3.0</version>
   <exclusions>
      <exclusion>
         <groupId>org.mybatis</groupId>
         <artifactId>mybatis</artifactId>
      </exclusion>
   </exclusions>
</dependency>

 文章借鉴:spring boot 集成 flowable 时mybatis-plus-core-3.1.2.jar 冲突 - 赵晓欣的个人空间 - OSCHINA - 中文开源技术交流社区

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
集成Flowable和表单需要以下步骤: 1. 添加Flowable和表单的依赖 在pom.xml文件中,添加以下依赖: ``` <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-spring-boot-starter</artifactId> <version>6.6.0</version> </dependency> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-form-spring-boot-starter</artifactId> <version>6.6.0</version> </dependency> ``` 2. 配置Flowable 在application.yml文件中,添加以下配置: ``` flowable: database-schema-update: true history-level: full ``` 3. 创建表单 创建表单的方式有多种,可以使用Flowable自带的表单设计器,也可以使用其他第三方表单设计器。在这里,我们以Flowable自带的表单设计器为例。 在Flowable Modeler中,创建一个新的模型,选择"Form"类型。然后,根据需求添加表单字段,并保存表单模型。 4. 部署流程 在Flowable Modeler中,创建一个新的模型,选择"BPMN"类型。然后,根据需求添加流程节点和连线,并在需要的节点上添加表单。 保存流程模型后,将其导出为.bpmn20.xml格式的文件,然后将该文件放置在classpath:/processes目录下。 5. 编写代码 在Spring Boot的启动类中,添加以下代码: ``` @Configuration public class MyProcessEngineConfiguration { @Bean public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) { SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration(); config.setDataSource(dataSource); config.setTransactionManager(transactionManager); config.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); config.setAsyncExecutorActivate(false); config.setHistoryLevel(HistoryLevel.FULL); return config; } @Bean public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration configuration) { ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean(); factoryBean.setProcessEngineConfiguration(configuration); return factoryBean; } @Bean public RepositoryService repositoryService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getRepositoryService(); } @Bean public RuntimeService runtimeService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getRuntimeService(); } @Bean public TaskService taskService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getTaskService(); } @Bean public FormService formService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getFormService(); } @Bean public HistoryService historyService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getHistoryService(); } @Bean public ManagementService managementService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getManagementService(); } @Bean public IdentityService identityService(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject().getIdentityService(); } @Bean public ProcessEngine processEngine(ProcessEngineFactoryBean factoryBean) throws Exception { return factoryBean.getObject(); } } ``` 这段代码的作用是创建ProcessEngine和各种服务对象,并将它们注入到Spring容器中。 然后,在需要使用表单的地方,可以使用以下代码获取表单: ``` FormService formService = ...; // 从Spring容器中获取FormService Object form = formService.getRenderedStartForm(processDefinitionId); // 获取流程定义的启动表单 ``` 以上就是集成Flowable和表单的步骤。需要注意的是,由于表单的渲染和提交是通过REST API实现的,因此还需要在应用程序中添加相关的REST API。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值