ps: 架构师交流群(QQ群号 304287620)
jBPM默认使用H2进行安装,本讲在安装后的基础,将数据库手指向mysql
1 创建mysql数据库
CREATE DATABASE jbpm;
create user 'jbpm'@'localhost' identified by 'jbpm';
grant all on jbpm.* to jbpm@'localhost';
FLUSH PRIVILEGES;
2 修改datasource
\jbpm-6.5.0.Final-installer-full\jbpm-installer\wildfly-10.0.0.Final\standalone\configuration\standalone-full.xml
<datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="MySQLDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/jbpm</connection-url>
<driver>mysql</driver>
<security>
<user-name>jbpm</user-name>
<password>jbpm</password>
</security>
</datasource>
3 修改数据库方言
\jbpm-6.5.0.Final-installer-full\jbpm-installer\wildfly-10.0.0.Final\standalone\deployments\jbpm-console.war
压缩工具打开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" />
将xml放入通过压缩工具打开的war,提示重新压缩
4 将com.mysql加入module
\jbpm-6.5.0.Final-installer-full\jbpm-installer\wildfly-10.0.0.Final\modules\system\layers\base底下创建文件夹com\mysql\main
并创建module.xml,注意xmlns="urn:jboss:module:1.3"的版本号1.3与其他module要保持一致,否则将无法正确找到此module
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
并把mysql-connector-java-5.1.18.jar放在此文件夹下
5 查看mysql数据库
可以看到64个表已创建
6 访问并可正常登录,到此切换至mysql完成
http://localhost:8080/jbpm-consolep
备注:
jboss产生的log文件,如果在修改过程中发现无法访问,可直接查看日志,快速定位问题
\jbpm-6.5.0.Final-installer-full\jbpm-installer\wildfly-10.0.0.Final\standalone\log\server.log
reference:
https://docs.jboss.org/jbpm/release/6.5.0.Final/jbpm-docs/html/ch03.html