1. Prepare the environment
1.Activiti software environment
1) JDK1.6 or higher;
2) Supported databases include: h2, mysql, oracle, postgres, mysql, db2, etc.;
3) Support jar packages running on active 5;
4) The development environment is Eclipse 3.7 or above, and myeclipse is version 8.6.
2. Download related resources
1) JDK can be downloaded from sun's official website;
2) Database, for example: mysql can be downloaded on the official website;
3) Activiti can also be downloaded from the Activiti official website;
4) Eclipse3.7 or MyEclipse8.6 can also be downloaded on the corresponding website.
2. Installation process designer (eclipse plug-in)
1. Installation method one
In the case of network, the steps for installing the process designer are as follows:
1) Open Help -> Install New Software. In the following panel:
2) In the Install interface panel below, click the Add button:
Configure the address and name of the newly installed plug-in
3) Then fill in the following fields Name: Activiti BPMN 2.0 designer Location: http://activiti.org/designer/update/
4) Return to the Install interface and check all displayed items in the middle of the panel:
5) Click the check box to check "Contact all updates sites.." in the Detail section, because it will check all plugins required for the current installation and can be downloaded by Eclipse.
6) After installation, click New Project New->Other... to open the panel, if you see the content of the following picture:
It means the installation is successful.
In the absence of a network, the steps for installing the process designer are as follows:
1) Download the jar package of the plug-in, download address: activiti-eclispe-plugin.rar
1) Unzip this jar package;
2) Put the contents in the compressed package into the drops folder of the root directory of eclipse;
3) Restart eclipse, click New->Other... to open the panel, if you see the content of the following image:
It means the installation is successful.
3. Instructions for using the process designer
Open the menu Windows->Preferences->Activiti->Save to generate process image:
Although the process engine will automatically generate pictures when deploying bpmn files separately, during the actual development process, the automatically generated pictures will cause differences from the coordinates in the BPMN, and there will be problems displaying the current position map of the process in the actual project. After completing the above configuration, we will manage the process pictures ourselves. When publishing the process, just upload the process rule files and process pictures together.
4. Prepare the Activiti5 development environment
4.0. Create an Activiti project
Click Finish to complete the creation
Create a successful project:
Our project is currently in a Maven structure, which contains pom.xml resource configuration. The business class is written in src/main/java, and the corresponding resource file is placed in src/main/resources. Similarly, the tested business class is under src/test/java, and the corresponding test resource file is placed under src/test/resources.
We create a new lib folder to place the jar package we are about to add for a while.
4.1. Add Activiti5 jar package
The following jar package needs to be added:
Download address: activerest(VeVB.COM).rar(There are all jars in the WEB-INF/lib folder of the sample project) We need to import all packages under lib. Add to classpath.
Since we are using Mysql database, the link driver of Mysql database is not provided in the official package of Activiti, and we need to import it ourselves. Manually import mysql-connector-java.jar and add it to classpath.
4.2 Initialize the database
We create a new junit package under src/test/java, and create a java class under the package called TestActiviti:
content:
package junit; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngineConfiguration; import org.junit.Test; public class TestActiviti { /**Use code to create 23 tables required for workflow*/ @Test public void createTable(){ // Process Engine ProcessEngine object, all operations are inseparable from the engine object ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration(); //Configuration of the connection database processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver"); processEngineConfiguration.setJdbcUrl("jdbc:mysql://localhost:3306/zhucoder2017?useUnicode=true&characterEncoding=utf8"); processEngineConfiguration.setJdbcUsername("root"); processEngineConfiguration.setJdbcPassword("1234"); //Three configurations//1. Delete the table first, and then create the table: processEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP="create-drop" //2. The table cannot be created automatically, the table needs to exist: processEngineConfiguration.DB_SCHEMA_UPDATE_FALSE="false" //3. If the table exists, the table will be created automatically: processEngineConfiguration.DB_SCHEMA_UPDATE_TRUE="true" processEngineConfiguration.setDatabaseSchema(processEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); //Get the core object of the workflow, ProcessEngine object ProcessEngine processEngine=processEngineConfiguration.buildProcessEngine(); System.out.println("processEngine:"+processEngine+"Create Success!!"); } }The above class first obtains the ProcessEngineConfiguration workflow engine configuration object to configure some database parameters, and then uses the configuration object to create the core object ProcessEngine object of the workflow, and uses the core engine object to create the 23 tables required for the workflow.
You can see that we have created the ProcessEngineConfiguration configuration class above, which configures the linked data of the database, so we also need to create the corresponding database. After installing Mysql, open our Mysql graphical management tool. Here I am using sqlyog:
After opening, we create the corresponding database (the database name is the same as the one in the linked class above):
Don't forget to add mysql's jdbc driver jar package to lib and then add it to classpath:
mysql-connector-java-5.1.10-bin.jar
After running our test class just now, after waiting for a while, you will find that the workflow core engine was created successfully:
This means that the 23 tables required for our workflow have been created successfully. We went to SQLyog to look at it and found that it did generate:
At this time, the environment for preparing Activiti has been prepared except for the configuration file.
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.