概述
通过部分ant install.demo安装完成的jBPM 6默认使用H2内存数据库,本文介绍如何使用 Mysql 替换默认的 H2 数据库。
创建所需要的Mysql数据库和用户
我们使用root用户登录Mysql,执行如下命令即可以完成创建:
CREATE DATABASE jbpm6;create user 'jbpm6_user'@'localhost' identified by 'jbpm6_pass';grant all on jbpm6.* to jbpm6_user@'localhost';FLUSH PRIVILEGES;
修改jbpmDS指向Mysql
jBPM 6默认使用的数据源为jbpmDS,它是通过standalone/configuration/standalone-full.xml文件配置的,我们根据中描述的方法,修改jbpmDS指向Mysql,配置完成如下:
jdbc:mysql://localhost:3306/jbpm6 mysql jbpm6_user jbpm6_pass
修改persistence.xml,使用MySQLDialect
打开 jbpm-console.war/WEB-INF/classes/META-INF/persistence.xml,修改<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />为<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
启动测试
为了简单我们可以将dashboard-builder.war从deployments下移除,这样我们只部署jbpm-console.war。我们使用如下目录启动JBoss 7:
./standalone.sh -c standalone-full.xml
启动完成通过访问测试。
启动完成到Mysql后台查看创建表情况如下:
mysql> show tables;+--------------------------------+| Tables_in_jbpm6 |+--------------------------------+| Attachment || BAMTaskSummary || BooleanExpression || Content || ContextMappingInfo || CorrelationKeyInfo || CorrelationPropertyInfo || Deadline || Delegation_delegates || ErrorInfo || Escalation || EventTypes || I18NText || NodeInstanceLog || Notification || Notification_BAs || Notification_Recipients || Notification_email_header || OrganizationalEntity || PeopleAssignments_BAs || PeopleAssignments_ExclOwners || PeopleAssignments_PotOwners || PeopleAssignments_Recipients || PeopleAssignments_Stakeholders || ProcessInstanceInfo || ProcessInstanceLog || Reassignment || Reassignment_potentialOwners || RequestInfo || SessionInfo || Task || TaskDef || TaskEvent || VariableInstanceLog || WorkItemInfo || email_header || task_comment |+--------------------------------+