日韩性视频-久久久蜜桃-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配置的全部內容,希望文章能夠幫你解決所遇到的問題。

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

    主站蜘蛛池模板: 久草资源站 | 国产福利一区二区三区视频 | 欧美乱论| 久久久久久久九九九九 | 污污视频在线 | 中文字幕精品一区久久久久 | 91精品在线观看视频 | 国产伦理在线观看 | 亚洲第一第二区 | 日韩伦乱 | 1024视频污 | 日韩av在线看免费观看 | 丰满少妇被猛烈进入一区二区 | 又色又爽又黄gif动态图 | 一区二区三区视频在线免费观看 | 91麻豆成人精品国产 | 国产原创麻豆 | 久久久久久高清 | 欧美精品久久久久久 | 一区=区三区乱码 | 99riav国产精品视频 | 爱情岛论坛亚洲品质自拍视频 | 日韩在线欧美在线 | 老司机午夜影院 | 亚洲精品自拍偷拍 | 精品一区二区三区成人免费视频 | 亚洲欧美激情在线观看 | 中国特级黄色大片 | 爱露出| 国产精品成人免费精品自在线观看 | 亚洲国产精品毛片 | 亚洲一区二区三区在线 | 久久国产人妻一区二区免色戒电影 | 大j8黑人w巨大888a片 | 国产精品99久久久久久大便 | 中国国产毛片 | av五十路| 97在线播放免费观看 | 深爱激情丁香 | v天堂在线观看 | 日韩乱码人妻无码中文字幕久久 | 精品欧美在线观看 | 操校花视频 | 6080av| 国产寡妇色xxⅹ交肉视频 | 国产成人精品一区二区三区 | 欧美精品99 | 草草影院在线观看视频 | 久一在线视频 | 麻豆久久久久久 | 成人一区在线观看 | 四虎精品在永久在线观看 | 亚洲国产精品视频在线 | 色婷婷综合久久久久中文 | 日本黄色一区二区三区 | 美女被揉胸视频 | 窝窝视频在线观看 | 日日骚av | 琪琪久久| 国产视频一区二区三区四区五区 | 国产成人精品aa毛片 | 欧美日韩不卡合集视频 | 自拍偷拍欧美视频 | 中文字幕一区二区人妻在线不卡 | 日韩人妻精品一区二区三区视频 | 在线日韩精品视频 | 国产精品亚洲一区二区 | 97色伦97色伦国产欧美空 | 毛片网站在线 | 日韩欧美国产片 | 99久久精品日本一区二区免费 | 一区二区精品 | 波多野结衣电影在线播放 | 成人av无码一区二区三区 | 日韩欧美中文字幕在线播放 | 又黄又色又爽的视频 | 高清av免费观看 | 少妇做爰免费视频播放 | 男同互操gay射视频在线看 | 91极品视频| 国产不卡av在线 | av免费成人| 91抖音在线观看 | 国产福利免费看 | 国产91久久精品一区二区 | 四虎影视成人永久免费观看亚洲欧美 | av影库| 女人17片毛片60分钟 | www.亚洲天堂 | 欧美精品一区二区三区久久 | 91在线观看免费 | 视频在线一区二区三区 | 校园伸入裙底揉捏1v1h | 久草免费网站 | 美女又爽又黄免费视频 | www.sesehu.com | 777毛片 | 男人午夜剧场 | 神马伦理影视 |