Activiti6.0教程(3) - springboot專案中使用activiti6.0配置及啟動
springboot整合非常的簡單,基本上不需要做配置, 而且專案啟動時自動會部署流程
建立專案
依賴如下
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring-boot-starter-basic</artifactId> <version>6.0.0</version> </dependency> </dependencies>
注意這裡要用6.0, 如果不寫這個版本號的話, springboot會自動下載7.0的activiti, 我在啟動的時候報了一個錯, jdk1.8沒法用, 至少要將jdk升級到9才能用activiti7.0
原連結文:https://tomoya92.github.io/2019/04/24/activiti-spring-boot/
修改配置檔案
application.yml
spring: datasource: username: root password: url: jdbc:mysql:///activiti-demo?useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2B8 activiti: database-schema-update: true
另外還要把流程圖檔案放在src/main/resources/processes
下, springboot預設是到這個資料夾裡去找流程圖進行部署的
而且還要把圖片的檔名修改一下, 假如流程圖名是AskLeave.bpmn
那麼在springboot專案中對應的圖片名就應該是AskLeave.AskLeave.png
啟動異常
這樣啟動它會報個錯, 錯誤資訊java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
這個問題當初我找了好久才找到啥問題, 是因為springboot的自動配置把SecurityAutoConfiguration
在專案啟動的時候也配置了, 這貨會導致報這個錯
解決辦法是在啟動為上的@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
配置不去自動配置即可
再次啟動就沒有問題了
總結
springboot專案啟動之後, 流程也就自動部署了, 如果流程在開發中間有變動的話, 再次啟動springboot專案的時候, 這個流程會重新部署, 即使定義的流程的名字沒變, 它也會重新部署一份, 後面再使用流程定義的Key來啟動流程就走的是新的流程了
寫部落格不易,轉載請保留原文連結,謝謝!
原文連結: