通过jBPM 6 发布,快速安装,新功能介绍部分ant install.demo安装完成的jBPM 6默认使用H2内存数据库,本文介绍如何使用 Mysql 替换默认的 H2 数据库。
我们使用root用户登录Mysql,执行如下命令即可以完成创建:
CREATE DATABASE jbpm6; create user 'jbpm6_user'@'localhost' identified by 'jbpm6_pass'; grant all on jbpm6.* to jbpm6_user@'localhost'; FLUSH PRIVILEGES;
jBPM 6默认使用的数据源为jbpmDS,它是通过standalone/configuration/standalone-full.xml文件配置的,我们根据JBoss 7/WildFly中配置使用Mysql数据库中描述的方法,修改jbpmDS指向Mysql,配置完成如下:
<datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true"> <connection-url>jdbc:mysql://localhost:3306/jbpm6</connection-url> <driver>mysql</driver> <security> <user-name>jbpm6_user</user-name> <password>jbpm6_pass</password> </security> </datasource>
打开 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
启动完成通过http://localhost:8080/jbpm-console访问测试。
启动完成到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 | +--------------------------------+