activiti study 2: Example of use engineering activiti-explorer.war

activiti study 2: Example of use engineering activiti-explorer.war

The main problem to solve is the main workflow: In order to achieve a business objective, the use of computers among multiple participants according to some predetermined rules to automatically transfer documents, information or tasks.

activiti official provided a sample project activiti-explorer.war, the project can run the basic functions of activiti experience, to understand the basic use of workflow.

As used herein, is activiti-5.22.0 official package,

download link

First, build a development environment

To run the sample project, you need to install jdk8 and tomcat. Which jdk need jdk8 or more, tomcat I am using tomcat8, use will be reported tomcat7 start when the following error:

严重: Exception sending context initialized event to listener instance of class org.activiti.explorer.servlet.WebConfigurer
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoDataConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.activiti.engine.IdentityService org.activiti.explorer.conf.DemoDataConfiguration.identityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'identityService' defined in class path resource [org/activiti/explorer/conf/ActivitiEngineConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.engine.IdentityService]: Factory method 'identityService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine' defined in class path resource [org/activiti/explorer/conf/ActivitiEngineConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.engine.ProcessEngine]: Factory method 'processEngine' threw exception; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineFactoryBean': FactoryBean threw exception on object creation; nested exception is java.util.ServiceConfigurationError: org.activiti.engine.cfg.ProcessEngineConfigurator: org.activiti.management.jmx.JMXConfigurator not a subtype
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.activiti.explorer.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5197)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5720)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1018)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.base/java.lang.Thread.run(Thread.java:844)

I do not understand is what causes this, but tomcat upgrade to version 8 can start.

Second, run the sample project

The activiti-5.22.0 official copy of which package unzip activiti-explorer.war to local tomcat webapps directory, and then start tomcat, in the browser to access http: // localhost: 8080 / activiti -explorer /, there will be the following login screen, you can use the default account password

kermit/kermit Log in

After a successful login, you can experience the basic functions of activiti in this example application.

Third, examples of projects Demo

The project is divided into four functional modules: tasks, processes, reports, management

Now I took off several functional modules using the process in accordance with the general terms

1. Create a flow chart

From the definition of the workflow, in order to achieve a business objective use of computers among multiple participants according to some predetermined rule to automatically transfer documents, information or tasks. You can know before using the workflow we need to define a rule where the rule refers to the flow chart.

进入流程管理模块,按如下菜单选则新建一个流程模型

流程-->流程设计工作区 -->新建模型

然后在新的页面中绘制一个简单的请假流程并保存。绘制流程图时注意要在用户任务的属性中分配assignment为当前的登录人kermit,这样才能在代办中看到新的任务。

如下是新建好的请假流程

这样流程图就创建好了。

2. 部署流程图

画好的流程图经过部署后才可以使用。在流程设计工作区选定刚才新建的流程,处理模型选择部署,完成流程的部署

3. 启动流程

部署完成后就可以启动这个流程,创建任务。在"已部署流程定义"中选中刚部署的流程,点击"启动流程"就可以启动流程。流程启动后就会在“任务”模块的"代办任务"中出现一个新的任务"apply vacation",这就是我们在流程图中定义的第一个用户任务。

这里要注意如果在画流程图时没有指定用户任务的assignee属性,或者指定的不是当前登录人的id,这个任务就不会出现在登录人的代办任务中

4. 完成任务

在任务模块对任务进行操作。在代办列表中找到刚才启动流程产生的那个任务,点击完成任务,流程就会走到下一个节点,并创建一个manager agree的任务,再完成这个任务,刚才开启的流程就结束了。

5. 用户管理

在管理模块的用户选项卡下可以对用户进行管理。这里的用户可以作为流程图上配置的assignees,使用对应账号登录后就可以操作各自的任务。

四、数据持久化

需要注意的是这个示例工程默认使用的是h2数据库,数据没有持久化到硬盘上,所以如果关闭tomcat后刚才操作的所有数据都会丢失,如果需要把操作数据持久化到硬盘上,就需要配置数据库设置,让示例工程连接本机上的mysql数据库。需要以下两个步骤:

(1) 修改war包中的配置文件,activiti-explorer\WEB-INF\classes\db.properties中的内容为以下内容

db=mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql:///activiti_explore
jdbc.username=root
jdbc.password=root

这样示例工程就连接上了本机上的mysql数据库

(2) 给该工程添加mysql的驱动jar包

该示例工程中是没有mysql的驱动的,所以这样配置后启动会报找不到数据库驱动的错误。复制一个驱动jar包到

activiti-explorer\WEB-INF\lib目录下,就完成添加。

重启tomcat,到数据库activiti_explore中查看,发现activiti自动了创建了需要的表结构,说明已经完成了数据持久化的配置。

五、总结

以上演示了如何使用activiti-5.22.0的示例工程 activiti-explorer.war如何使用。需要注意的是这个示例工程默认使用的是h2数据库,数据没有持久化到硬盘上,所以如果关闭tomcat后刚才操作的所有数据都会丢失。

如果需要把操作数据持久化到硬盘上,就需要配置数据库设置,让示例工程连接本机上的mysql数据库。

Guess you like

Origin www.cnblogs.com/chengxuxiaoyuan/p/12002867.html