日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring boot 集成工作流flowable去掉xml配置

發布時間:2025/3/21 javascript 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring boot 集成工作流flowable去掉xml配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

工作流Flowable和Spring集成時,有一個xml是用來配置ProcessEngine的信息,xml的內容如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsdhttp://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"><!-- Activiti begin --><bean id="processEngineConfiguration" class="com.xxx.xxx.config.ExtProcessEngineConfiguration"><property name="dataSource" ref="dataSource" /><property name="transactionManager" ref="transactionManager" /><property name="databaseSchemaUpdate" value="true" /><!-- property name="jobExecutorActivate" value="false" /--><property name="customSessionFactories"><list><bean class="com.xxx.xxx.entity.EntityManagerFactory"><constructor-arg index="0" value="org.flowable.idm.engine.impl.persistence.entity.UserEntityManager" /><constructor-arg index="1"><bean class="com.xxx.xxx.entity.SmartUserEntityManager"/></constructor-arg></bean><bean class="com.xxx.xxx.entity.EntityManagerFactory"><constructor-arg index="0" value="org.flowable.idm.engine.impl.persistence.entity.GroupEntityManager" /><constructor-arg index="1"><bean class="com.xxx.xxx.entity.SmartGroupEntityManager"/></constructor-arg></bean><bean class="com.xxx.xxx.entity.EntityManagerFactory"><constructor-arg index="0" value="org.flowable.idm.engine.impl.persistence.entity.MembershipEntityManager" /><constructor-arg index="1"><bean class="com.xxx.xxx.entity.SmartMembershipEntityManager"/></constructor-arg></bean></list></property></bean><bean id="processEngine" factory-bean="processEngineConfiguration" factory-method="buildProcessEngine" /><bean id="repositoryService" factory-bean="processEngineConfiguration" factory-method="getRepositoryService" /><bean id="runtimeService" factory-bean="processEngineConfiguration" factory-method="getRuntimeService" /><bean id="taskService" factory-bean="processEngineConfiguration" factory-method="getTaskService" /><bean id="historyService" factory-bean="processEngineConfiguration" factory-method="getHistoryService" /><bean id="managementService" factory-bean="processEngineConfiguration" factory-method="getManagementService" /><bean id="formService" factory-bean="processEngineConfiguration" factory-method="getFormService" /><bean id="identityService" factory-bean="processEngineConfiguration" factory-method="getIdentityService" /><bean id="commandExecutor" factory-bean="processEngineConfiguration" factory-method="getCommandExecutor" /><bean id="processDefinitionCache" factory-bean="processEngineConfiguration" factory-method="getProcessDefinitionCache"/></beans>

使用Spring boot之后推崇java配置取代xml配置,要對這個xml進行改造首先得搞清楚這個xml里面的內容,主要是定義了ExtProcessEngineConfiguration和它相關的屬性,

  • 說明:?
    constructor-arg:通過構造函數注入。?
    property:通過setter對應的方法注入。?
    factory-method:通過工廠方法來構造java Bean

  • 創建config配置文件WorkflowConfiguration,在這個類中通過@bean的注解構造ExtProcessEngineConfiguration 類,同時設置ExtProcessEngineConfiguration 需要的幾個屬性

  • @Configuration public class WorkflowConfiguration {private final DataSource dataSource;private final PlatformTransactionManager transactionManager;public WorkflowConfiguration(DataSource dataSource,PlatformTransactionManager transactionManager){this.dataSource = dataSource;this.transactionManager = transactionManager;}@Beanpublic SmartUserEntityManager smartUserEntityManager() {return new SmartUserEntityManager(new ExtProcessEngineConfiguration());}@Beanpublic SmartGroupEntityManager smartGroupEntityManager() {return new SmartGroupEntityManager(new ExtProcessEngineConfiguration());}@Beanpublic SmartMembershipEntityManager smartMembershipEntityManager() {return new SmartMembershipEntityManager(new ExtProcessEngineConfiguration());}public EntityManagerFactory userEntityManagerFactory(){EntityManagerFactory entityManagerFactory = new EntityManagerFactory(UserEntityManager.class, smartUserEntityManager());return entityManagerFactory;}public EntityManagerFactory groupEntityManagerFactory(){EntityManagerFactory entityManagerFactory = new EntityManagerFactory(GroupEntityManager.class, smartGroupEntityManager());return entityManagerFactory;}public EntityManagerFactory membershipEntityManagerFactory(){EntityManagerFactory entityManagerFactory = new EntityManagerFactory(MembershipEntityManager.class, smartMembershipEntityManager());return entityManagerFactory;}@Beanpublic ExtProcessEngineConfiguration engineConfiguration(){ExtProcessEngineConfiguration engineConfiguration = new ExtProcessEngineConfiguration();engineConfiguration.setDatabaseSchemaUpdate("true");engineConfiguration.setDataSource(dataSource);engineConfiguration.setTransactionManager(transactionManager);List<SessionFactory> customSessionFactories = new ArrayList<>();customSessionFactories.add(userEntityManagerFactory());customSessionFactories.add(groupEntityManagerFactory());customSessionFactories.add(membershipEntityManagerFactory());engineConfiguration.setCustomSessionFactories(customSessionFactories);return engineConfiguration;}}

    其中核心的代碼是:

    @Beanpublic ExtProcessEngineConfiguration engineConfiguration()

    這個方法。

    其中有一個重點需要注意的地方是,在xml里面有一段:

    <bean id="processEngine" factory-bean="processEngineConfiguration" factory-method="buildProcessEngine" />

    這個是Spring使用實例工廠方法實例化Bean的一種方式,工作作流引擎Flowable的各個組件就是使用此方式實例化的。由于使用工廠實例化的Bean跟普通Bean不同,其返回的對象不是指定類的一個實例,其返回的是該FactoryBean的getObject方法所返回的對象。因此我們需要使用Spring Boot的方式來實例化Flowable的組件。有兩種解決方法:

  • 自定義FactoryBean,實現FactoryBean中的getObject這個方法,返回ProcessEngine對象
  • 使用ProcessEngineFactoryBean,推薦使用這種方式,以下為ProcessEngineFactoryBean源碼。
  • public class ProcessEngineFactoryBean implements FactoryBean<ProcessEngine> ..{...protected ProcessEngineImpl processEngine;public ProcessEngine getObject() throws Exception {initializeExpressionManager();initializeTransactionExternallyManaged();if (processEngineConfiguration.getBeans()==null) {processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(applicationContext));}processEngine = (ProcessEngineImpl) processEngineConfiguration.buildProcessEngine();return processEngine;}... }

    ProcessEngineFactoryBean最終返回的是processEngine對象,repositoryService、runtimeService、formService等等組件都是通過processEngine里的getXX方法獲得的。

    通過WorkflowConfiguration就可以取代xml配置文件了。

    在我們需要繼承flowable-restApi的時候發現需要進行權限校驗,我們可以通過下面的注解去掉security權限校驗,在啟動類上加上下面的注解:

    @SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.class,org.flowable.spring.boot.SecurityAutoConfiguration.class})

    ?

    總結

    以上是生活随笔為你收集整理的Spring boot 集成工作流flowable去掉xml配置的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 亚洲AV永久无码国产精品国产 | 都市激情男人天堂 | 狠狠操中文字幕 | 色综合图片区 | 私密视频在线观看 | 国内自拍小视频 | 久久精品视频一区二区三区 | 青青青青青青草 | 伊人伊人| 日韩午夜视频在线观看 | www.xxx.国产 | 国产成人精品国内自产拍免费看 | 久草三级 | 欧洲人妻丰满av无码久久不卡 | 色一情一交一乱一区二区三区 | 黑白配高清国语在线观看 | 国产免费一区二区三区在线观看 | 毛片毛片女人毛片毛片 | 国产偷人爽久久久久久老妇app | 97人人爱 | 一区二区三区免费观看 | 天操夜夜操 | 成年网站 | 男男巨肉啪啪动漫3d | 日韩欧美一二区 | 色啪网站 | 成年人国产精品 | 国产寡妇色xxⅹ交肉视频 | 国产精品久久久久久久一区探花 | 欧美巨大荫蒂茸毛毛人妖 | 妺妺窝人体色www在线下载 | 免费毛片观看 | 色女人天堂 | 99热在线观看免费 | 国产91清纯白嫩初高中在线观看 | 欧美性生活精品 | 另类激情 | 国产片黄色 | 内射无码专区久久亚洲 | 操女人视频网站 | 少女视频的播放方法 | 久久久噜噜噜久久中文字幕色伊伊 | 精品欧美乱码久久久久久 | 色窝在线 | 亚洲人成网址 | 国产亚州av | 风间ゆみ大战黑人 | 欧美特级黄色大片 | a级大片在线观看 | 暖暖日本在线视频 | 91免费在线观看网站 | 伦一理一级一a一片 | 香港三级日本三级三69 | av一区二区三区四区 | 亚洲最大黄网 | 日韩成年视频 | 五月天综合色 | www.欧美| 啪啪免费小视频 | 国产sm网站 | 豆花在线视频 | 麻豆传媒网站在线观看 | 伊朗做爰xxxⅹ性视频 | 亚洲男人天堂网站 | 欧美偷拍综合 | 成人免费毛片男人用品 | 9l视频自拍九色9l视频 | 在线看国产 | 日韩av在线不卡 | 国产视频不卡 | 亚洲精品网站在线观看 | 性的免费视频 | 亚洲一区二区美女 | 丰满熟女一区二区三区 | 姝姝窝人体www聚色窝 | 亚洲精选免费 | 欧美成人影音 | 日本亚洲在线 | 亚洲精品国产成人久久av盗摄 | 日本国产在线视频 | 91免费视频网址 | 国产又粗又猛又黄 | 爱搞逼综合网 | 色综合天天综合网天天看片 | 麻豆影视网站 | 一区二视频 | 精品国产区 | 天堂av网址 | 肉肉av福利一精品导航 | youjizzxxxxx| 亚洲在线免费 | 欧美aaa级片| 国内老熟妇对白hdxxxx | 久久aⅴ国产欧美74aaa | av大片在线免费观看 | 伊人tv| av青娱乐| 国产精品久久久一区 | 欧美黑人精品一区二区 |