activiti使用詳解(一)
簡單的api程式示例(maven工程):
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.activiti.examples</groupId> <artifactId>activiti-examples</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>BPMN 2.0 with Activiti - Examples</name> <properties> <activiti-version>5.18.0</activiti-version> </properties> <dependencies> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-engine</artifactId> <version>${activiti-version}</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring</artifactId> <version>${activiti-version}</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>2.4.3</version> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.168</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.7.6</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> <!-- MySQL驅動 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.29</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <inherited>true</inherited> <configuration> <classpathContainers> <classpathContainer>org.eclipse.jdt.USER_LIBRARY/Activiti Designer Extensions</classpathContainer> </classpathContainers> </configuration> </plugin> </plugins> </build> </project> |
第一種方式使用程式碼形式建立資料庫(不推薦,建議使用方法二的:配置檔案):
package junit;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
public class TestActivit{
@Test
public void creatTable(){
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
processEngineConfiguration.setJdbcUrl("jdbc:mysql://172.31.2.14:3306/activiti?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true");
processEngineConfiguration.setDatabaseSchemaUpdate(processEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP);
processEngineConfiguration.setJdbcUsername("root");
processEngineConfiguration.setJdbcPassword("yunjisuan");
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
}
}
|
方法二(使用spring 配置檔案依賴注入-建議使用此方法):
package junit;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
public class TestActivit{
@Test
public void creatTable(){
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
processEngineConfiguration.setJdbcUrl("jdbc:mysql://172.31.2.14:3306/activiti?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true");
processEngineConfiguration.setDatabaseSchemaUpdate(processEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP);
processEngineConfiguration.setJdbcUsername("root");
processEngineConfiguration.setJdbcPassword("yunjisuan");
processEngineConfiguration.buildProcessEngine();
}
@Test
public void creatTable2(){
ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
}
}
|
需要增加一個配置檔案:
相關文章
- 工作流中的資料持久化詳解!Activiti框架中JPA的使用分析持久化框架
- 工作流引擎詳解!工作流開源框架ACtiviti的詳細配置以及安裝和使用框架
- Activiti(一) activiti資料庫表說明資料庫
- 詳解工作流框架Activiti的服務架構和元件框架架構元件
- Activiti 統一身份管理
- activiti
- Jpa使用詳解
- mitmproxy使用詳解MIT
- Thymeleaf使用詳解
- mydumper使用詳解
- babel使用詳解Babel
- git使用詳解Git
- Mat使用詳解
- Proxy使用詳解
- nvm 使用詳解
- CSSModules使用詳解CSSSSM
- ctags使用詳解
- AutoLayout 使用詳解
- umask使用詳解
- OkHttp使用詳解HTTP
- Okhttp 使用詳解HTTP
- Inception使用詳解
- UITableView使用詳解UIView
- ViewFlipper使用詳解View
- NULL 使用詳解Null
- ASIHttpRequest使用詳解HTTP
- at命令使用詳解
- LOMBOK使用詳解Lombok
- 一文詳解Spring Boot的使用Spring Boot
- SpringBoot整合Activiti7使用Spring Boot
- 工作流引擎Activiti使用進階!詳細解析工作流框架中高階功能的使用示例框架
- 五分鐘瞭解Activiti工作流
- SpringBoot整合Activiti學習(一)Spring Boot
- Sequlize詳解(一)
- MyBatis詳解(一)MyBatis
- jdbc詳解(一)JDBC
- Activiti Exploer工作流控制檯使用指南!使用Activiti Explorer定義部署執行工作流
- 一、.Net Core 依賴注入詳解及Autofac使用依賴注入