最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

解決mybatis+springboot+flowable6.4.0遇到的問題

 更新時間:2025年11月14日 09:32:55   作者:ToBeYourBaBa  
文章主要介紹了MyBatis和Flowable在Spring Boot項目中的沖突問題,以及如何通過排除Flowable的SQLSession注入、增加Flowable屬性配置和處理數(shù)據(jù)庫表錯誤來解決這個問題

問題

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

寫錯對應(yīng)關(guān)系 namespace等騷操作造成的就不說了。動動腦子。下面主要說沖突導致的這個問題。

源碼查看

1 報錯位置

 MappedStatement ms = resolveMappedStatement(mapperInterface, methodName, declaringClass,
          configuration);
      if (ms == null) {
        if (method.getAnnotation(Flush.class) != null) {
          name = null;
          type = SqlCommandType.FLUSH;
        } else {
          throw new BindingException("Invalid bound statement (not found): "
              + mapperInterface.getName() + "." + methodName);
        }
        ...

2 ms為啥為空 因為 mappedStatements里沒有(MapperLocations配置沒生效)

private MappedStatement resolveMappedStatement(Class<?> mapperInterface, String methodName,
        Class<?> declaringClass, Configuration configuration) {
      String statementId = mapperInterface.getName() + "." + methodName;
      if (configuration.hasStatement(statementId)) {
        return configuration.getMappedStatement(statementId);
      } else if (mapperInterface.equals(declaringClass)) {
        return null;
      }
  public boolean hasStatement(String statementName) {
    return hasStatement(statementName, true);
  }

  public boolean hasStatement(String statementName, boolean validateIncompleteStatements) {
    if (validateIncompleteStatements) {
      buildAllStatements();
    }
    return mappedStatements.containsKey(statementName);
  }

3 真正原因! @ConditionalOnMissingBean ?。。。。喝绻萜髦袥]有,就注入,如果有就不注入.mybatis的sqlsession被flowable的覆蓋了

mybatis的:org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration里
@Bean
   @ConditionalOnMissingBean
   public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
  	 ...
   factory.setMapperLocations(this.properties.resolveMapperLocations());
  	...
   }
   
flowable的:org.flowable.ui.modeler.conf.DatabaseConfiguration里
@Bean
   public SqlSessionFactory sqlSessionFactory(DataSource dataSource) {
       SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
       sqlSessionFactoryBean.setDataSource(dataSource);
       String databaseType = this.initDatabaseType(dataSource);
       if (databaseType == null) {
           throw new FlowableException("couldn't deduct database type");
       } else {
           try {
               Properties properties = new Properties();
               properties.put("prefix", this.modelerAppProperties.getDataSourcePrefix());
               properties.put("blobType", "BLOB");
               properties.put("boolValue", "TRUE");
               properties.load(this.getClass().getClassLoader().getResourceAsStream("org/flowable/db/properties/" + databaseType + ".properties"));
               sqlSessionFactoryBean.setConfigurationProperties(properties);
               sqlSessionFactoryBean.setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(this.resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));
               sqlSessionFactoryBean.afterPropertiesSet();
               return sqlSessionFactoryBean.getObject();
           } catch (Exception var5) {
               throw new FlowableException("Could not create sqlSessionFactory", var5);
           }
       }
   }

4 很明顯,mybatis的配置被覆蓋了。吐槽一下flowable-ui的源碼!

解決辦法

就是兼顧 flowable和mybatis的配置

1 第一步 排除flowable的sqlsession注入:

在@ComponentScan里加入這樣的話。
@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DatabaseConfiguration.class)

2 第二步 增加flowable的屬性配置等。application.properties里添加如下配置。加modeler-mybatis-mapping那個

mybatis.mapperLocations=classpath*:mapper/*/*.xml,classpath:/META-INF/modeler-mybatis-mappings/*.xml
#這里就是配個空?;蛘吲渲脭?shù)據(jù)庫用戶名 username也行,不要瞎改哈(這個是查詢前綴-flowable)
mybatis.configuration-properties.prefix =
mybatis.configuration-properties.blobType = BLOB
mybatis.configuration-properties.boolValue = TRUE

3 第三步,做到這直接啟動項目可能會報 act_de_model表找不到等錯誤。再一個@Configuration配置里加入以下bean的注入

@Bean
  public Liquibase liquibase(DataSource dataSource) {
      Liquibase liquibase = null;

      Liquibase var5;
      try {
          DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
          Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
          database.setDatabaseChangeLogTableName("ACT_DE_" + database.getDatabaseChangeLogTableName());
          database.setDatabaseChangeLogLockTableName("ACT_DE_" + database.getDatabaseChangeLogLockTableName());
          liquibase = new Liquibase("META-INF/liquibase/flowable-modeler-app-db-changelog.xml", new ClassLoaderResourceAccessor(), database);
          liquibase.update("flowable");
          var5 = liquibase;
      } catch (Exception var9) {
          throw new InternalServerErrorException("Error creating liquibase database", var9);
      } finally {
      }
      return var5;
  }

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • spring定時器@Scheduled異步調(diào)用方式

    spring定時器@Scheduled異步調(diào)用方式

    在Spring Boot中,@Schedule默認使用單線程執(zhí)行定時任務(wù),多個定時器會按順序執(zhí)行,為實現(xiàn)異步執(zhí)行,可以通過自定義線程池或?qū)崿F(xiàn)SchedulingConfigurer接口,使用自定義線程池可以保證多個定時器并發(fā)執(zhí)行
    2024-11-11
  • JAVA調(diào)用JavaScript方法舉例詳解

    JAVA調(diào)用JavaScript方法舉例詳解

    之前在一次機緣巧合的情況下,需要時用JAVA執(zhí)行js方法,查閱了一些文檔,找到了相關(guān)解決方法,這里和大家分享一下,下面這篇文章主要給大家介紹了關(guān)于JAVA調(diào)用JavaScript方法的相關(guān)資料,需要的朋友可以參考下
    2023-10-10
  • eclipse修改jvm參數(shù)調(diào)優(yōu)方法(2種)

    eclipse修改jvm參數(shù)調(diào)優(yōu)方法(2種)

    本篇文章主要介紹了eclipse修改jvm參數(shù)調(diào)優(yōu)方法(2種),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-02-02
  • 淺析Java 數(shù)據(jù)結(jié)構(gòu)常用接口與類

    淺析Java 數(shù)據(jù)結(jié)構(gòu)常用接口與類

    本篇文章主要介紹了Java中的數(shù)據(jù)結(jié)構(gòu),Java工具包提供了強大的數(shù)據(jù)結(jié)構(gòu)。需要的朋友可以參考下
    2017-04-04
  • Spring Boot 集成 Sharding-JDBC + Mybatis-Plus 實現(xiàn)分庫分表功能

    Spring Boot 集成 Sharding-JDBC + Mybatis-Plus 實現(xiàn)分庫分表功能

    這篇文章主要介紹了Spring Boot 集成 Sharding-JDBC + Mybatis-Plus 實現(xiàn)分庫分表功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-08-08
  • Spring boot webService使用方法解析

    Spring boot webService使用方法解析

    這篇文章主要介紹了Spring boot webService使用方法解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-09-09
  • Spring?BOOT?AOP基礎(chǔ)應(yīng)用教程

    Spring?BOOT?AOP基礎(chǔ)應(yīng)用教程

    這篇文章主要介紹了Spring?BOOT?AOP的使用,文章從相關(guān)問題展開全文內(nèi)容詳情,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-07-07
  • 關(guān)于dubbo的超時處理及重試原則

    關(guān)于dubbo的超時處理及重試原則

    這篇文章主要介紹了關(guān)于dubbo的超時處理及重試原則,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • Java?IO流之StringWriter和StringReader用法分析

    Java?IO流之StringWriter和StringReader用法分析

    這篇文章主要介紹了Java?IO流之StringWriter和StringReader用法分析,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Java獲取項目路徑方式System.getProperty(“user.dir“)

    Java獲取項目路徑方式System.getProperty(“user.dir“)

    這篇文章主要介紹了Java獲取項目路徑方式System.getProperty(“user.dir“),具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12

最新評論

阳信县| 太谷县| 白银市| 息烽县| 应用必备| 亚东县| 巧家县| 方山县| 德清县| 沐川县| 潞西市| 收藏| 运城市| 沁源县| 东海县| 东宁县| 准格尔旗| 民和| 澎湖县| 琼中| 报价| 乌恰县| 梁河县| 洞口县| 界首市| 武乡县| 兴海县| 玛纳斯县| 越西县| 桐城市| 丰宁| 云安县| 阜城县| 理塘县| 额济纳旗| 若尔盖县| 邹城市| 大城县| 南阳市| 马尔康县| 古交市|