关闭

jBPM5.4.0:使用MySql数据库

956人阅读 评论(0) 收藏 举报
分类:

需要修改的文件为:

  • build.properties
  • build.xml
  • db/jbpm-persistence-JPA2.xml
  • db/task-persistence-JPA2.xml
  • standalone.xml
  • task-service/resources/META-INF/persistence.xml
  • lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml
  • lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml

     

    1.下载MySql驱动放在安装目录/db/drivers/下。这里将名字修改为mysql-connector-java.jar。

    在MySql数据库中创建task和jbpm数据库。

    1. mysql> CREATE DATEBASE IF NOT EXISTS jbpm5;  
    2. mysql> CREATE USER 'jbmp5'@'localhost' IDENTIFIED BY 'jbpm5';  
    3. mysql> GRANT ALL PRIVILEGES ON jbpm5.* TO 'jbpm5'@'localhost';  
    1. mysql> CREATE DATEBASE IF NOT EXISTS task;  
    2. mysql> CREATE USER 'task'@'localhost' IDENTIFIED BY 'task';  
    3. mysql> GRANT ALL PRIVILEGES ON task.* TO <a href="mailto:'task'@'localhost;">'task'@'localhost;  

    2.修改db/jbpm-persistence-JPA2.xml和task-persistence-JPA2.xml,修改方式类似

    Xml代码
    1. 将  
    2. <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />  
    3. 或  
    4. <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>  
    5. 修改为  
    6. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />  

    附:

    Hibernate SQL Dialects (hibernate.dialect)

    RDBMS Dialect
    DB2 org.hibernate.dialect.DB2Dialect
    DB2 AS/400 org.hibernate.dialect.DB2400Dialect
    DB2 OS390 org.hibernate.dialect.DB2390Dialect
    PostgreSQL org.hibernate.dialect.PostgreSQLDialect
    MySQL

    org.hibernate.dialect.MySQLDialect

    org.hibernate.dialect.MySQL5Dialect

    MySQL with InnoDB org.hibernate.dialect.MySQLInnoDBDialect
    MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect
    Oracle (any version) org.hibernate.dialect.OracleDialect
    Oracle 9i org.hibernate.dialect.Oracle9iDialect
    Oracle 10g org.hibernate.dialect.Oracle10gDialect
    Sybase org.hibernate.dialect.SybaseDialect
    Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect
    Microsoft SQL Server org.hibernate.dialect.SQLServerDialect
    SAP DB org.hibernate.dialect.SAPDBDialect
    Informix org.hibernate.dialect.InformixDialect
    HypersonicSQL org.hibernate.dialect.HSQLDialect
    Ingres org.hibernate.dialect.IngresDialect
    Progress org.hibernate.dialect.ProgressDialect
    Mckoi SQL org.hibernate.dialect.MckoiDialect
    Interbase org.hibernate.dialect.InterbaseDialect
    Pointbase org.hibernate.dialect.PointbaseDialect
    FrontBase org.hibernate.dialect.FrontbaseDialect
    Firebird org.hibernate.dialect.FirebirdDialect

    3.修改task-service/resources/META-INF/persistence.xml
    Xml代码
    1. <properties>  
    2.       <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>  
    3.       <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>  
    4.       <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/runtime/task" />  
    5.       <property name="hibernate.connection.username" value="sa"/>  
    6.       <property name="hibernate.connection.password" value=""/>  
    7.       <property name="hibernate.connection.autocommit" value="false" />  
    8.       <property name="hibernate.max_fetch_depth" value="3"/>  
    9.       <property name="hibernate.hbm2ddl.auto" value="create" />  
    10.       <property name="hibernate.show_sql" value="false" />  
    11.     </properties>  
    12. 修改为  
    13. <properties>  
    14.       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>  
    15.       <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>  
    16.       <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/task" />  
    17.       <property name="hibernate.connection.username" value="task"/>  
    18.       <property name="hibernate.connection.password" value="task"/>  
    19.       <property name="hibernate.connection.autocommit" value="false" />  
    20.       <property name="hibernate.max_fetch_depth" value="3"/>  
    21.       <property name="hibernate.hbm2ddl.auto" value="create" />  
    22.       <property name="hibernate.show_sql" value="false" />  
    23.     </properties>  

    4.修改db/mysql_module.xml中jar的名称为mysql.jar,与db/drivers中的jar名称对应。

    Xml代码
    1. <resources>  
    2.      <resource-root path="mysql-connector-java.jar"/>  
    3. </resources>  

    5.使用的是Jboss7,修改安装目录下的standalone.xml
    1. 将  
    2. <subsystem xmlns="urn:jboss:domain:datasources:1.0">  
    3.             <datasources>  
    4.                 <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">  
    5.                     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>  
    6.                     <driver>h2</driver>  
    7.                     <security>  
    8.                         <user-name>sa</user-name>  
    9.                         <password>sa</password>  
    10.                     </security>  
    11.                 </datasource>  
    12.                 <datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">  
    13.                     <connection-url>jdbc:h2:~/jbpm</connection-url>  
    14.                     <driver>h2</driver>  
    15.                     <pool>  
    16.                         <min-pool-size>1</min-pool-size>  
    17.                         <max-pool-size>4</max-pool-size>  
    18.                         <prefill>false</prefill>  
    19.                         <use-strict-min>false</use-strict-min>  
    20.                         <flush-strategy>FailingConnectionOnly</flush-strategy>  
    21.                     </pool>  
    22.                     <security>  
    23.                         <user-name>sa</user-name>  
    24.                     </security>  
    25.                     <validation>  
    26.                         <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>  
    27.                         <validate-on-match>false</validate-on-match>  
    28.                         <background-validation>false</background-validation>  
    29.                     </validation>  
    30.                 </datasource>  
    31.                 <drivers>  
    32.                     <driver name="h2" module="com.h2database.h2">  
    33.                         <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>  
    34.                     </driver>  
    35.                 </drivers>  
    36.             </datasources>  
    37.         </subsystem>  
    38. 修改为  
    39. <subsystem xmlns="urn:jboss:domain:datasources:1.0">  
    40.             <datasources>  
    41.                 <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">  
    42.                     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>  
    43.                     <driver>h2</driver>  
    44.                     <security>  
    45.                         <user-name>sa</user-name>  
    46.                         <password>sa</password>  
    47.                     </security>  
    48.                 </datasource>  
    49.                 <datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">  
    50.                     <connection-url>jdbc:mysql://localhost:3306/jbpm5</connection-url>  
    51.                     <driver>mysql</driver>  
    52.                     <pool>  
    53.                         <min-pool-size>1</min-pool-size>  
    54.                         <max-pool-size>4</max-pool-size>  
    55.                         <prefill>false</prefill>  
    56.                         <use-strict-min>false</use-strict-min>  
    57.                         <flush-strategy>FailingConnectionOnly</flush-strategy>  
    58.                     </pool>  
    59.                     <security>  
    60.                         <user-name>jbpm5</user-name>  
    61.             <password>jbpm5</password>  
    62.                     </security>  
    63.                     <validation>  
    64.                         <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>  
    65.                         <validate-on-match>false</validate-on-match>  
    66.                         <background-validation>false</background-validation>  
    67.                     </validation>  
    68.                 </datasource>  
    69.                 <drivers>  
    70.                     <driver name="mysql" module="com.mysql">  
    71.                         <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>  
    72.                     </driver>  
    73.                 </drivers>  
    74.             </datasources>  
    75.         </subsystem>  
    6.修改安装目录下的build.properties,将数据库的配置从H2,改为MySqlcopy
    1. # default is H2  
    2. #db.name=h2  
    3. #db.driver.jar.name=${db.name}.jar  
    4. #db.driver.download.url=http://repo1.maven.org/maven2/com/h2database/h2/${H2.version}/h2-${H2.version}.jar  
    5. #other options are mysql  
    6.   db.name=mysql  
    7.   db.driver.module.prefix=com/mysql  
    8.   db.driver.jar.name=${db.name}.jar  
    9.   db.driver.download.url=https://repository.jboss.org/nexus/service/local/repositories/central/content/mysql/mysql-connector-java/5.1.18/mysql-connector-java-5.1.18.jar  
    7.修改/lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml文件中的hibernate.dialect
    Xml代码copy
    1. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>  
    8.修改/lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml文件中的hibernate.dialect和hibernate.hbm2ddl.auto。
    Xml代码copy
    1. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />  
    2.   
    3. <property name="hibernate.hbm2ddl.auto" value="create" />  
    9.修改build.xml
    Xml代码
    1. 在  
    2.  <java classname="org.jbpm.DemoTaskService" fork="true">    
    3.       <classpath>  
    4.         <pathelement path="${install.home}/task-service/target"/>  
    5.         <path refid="classpath.human.task" />  
    6.       </classpath>  
    7.     </java>  
    8.   
    9. 中加  
    10. <sysproperty key="jbpm.user.group.mapping" value="file:///F:/PDF/jbpm/jbpm-installer/jboss-as-7.1.1.Final/standalone/configuration/roles.properties"/>   
    11. 变为  
    12.  <java classname="org.jbpm.DemoTaskService" fork="true">    
    13.       <sysproperty key="jbpm.user.group.mapping" value="file:///F:/PDF/jbpm/jbpm-installer/jboss-as-7.1.1.Final/standalone/configuration/roles.properties"/>   
    14.       <classpath>  
    15.         <pathelement path="${install.home}/task-service/target"/>  
    16.         <path refid="classpath.human.task" />  
    17.       </classpath>  
    18.     </java>  
    19. 根据你的实际目录修改  
     
    1. <!-- Start Demo -->  
    2. <target name="start.demo" depends="start.h2,start.jboss,start.eclipse" />  
    3.   
    4. <!-- Start Demo (Eclipse) -->  
    5. <target name="start.demo.eclipse" depends="start.h2,start.eclipse" />  
    6.   
    7. <!-- Start Demo (No Eclipse)-->  
    8. <target name="start.demo.noeclipse" depends="start.h2,start.jboss" />  
    9.   
    10. <!-- Stop Demo -->  
    11. <target name="stop.demo" depends="stop.h2,stop.jboss" />  

    中加
    1. <!-- Start Demo -->  
    2. <target name="start.demo" depends="start.h2,start.jboss,start.eclipse" />  
    3.   
    4. <!-- Start Demo (DB) -->  
    5. <target name="start.demo.db" depends="start.jboss, start.eclipse" />  
    6.   
    7. <!-- Start Demo (DB, No Eclipse) -->  
    8. <target name="start.demo.db.noeclipse" depends="start.jboss" />  
    9.   
    10. <!-- Start Demo (Eclipse) -->  
    11. <target name="start.demo.eclipse" depends="start.h2,start.eclipse" />  
    12.   
    13. <!-- Start Demo (No Eclipse)-->  
    14. <target name="start.demo.noeclipse" depends="start.h2,start.jboss" />  
    15.   
    16. <!-- Stop Demo -->  
    17. <target name="stop.demo" depends="stop.h2,stop.jboss" />  
    18.   
    19. <!-- Stop Demo (DB)-->  
    20. <target name="stop.demo.db" depends="stop.jboss" />  
    10.在CMD中到你的安装目录下,运行
    Java代码
    1. ant install.demo  
    2. 或  
    3. ant install.demo.noeclipse  
    11.运行
    Java代码
    1. ant start.human.task  
    创建task数据库表 ,创建完成后按Ctrl+C,再按退出创建。
    12.运行
    Java代码copy
    1. ant start.jboss  
    启动,会创建jbpm数据库表。
    启动成功后再运行
    Java代码
    1. ant stop.jboss  
    成功关闭后修改安装目录下\jboss-as-7.1.1.Final\standalone\deployments\jbpm-gwt-console-server.war\WEB-INF/classes/META-INF/persistence.xml文件中的hibernate.hbm2ddl.auto。
    Xml代码
    1. <propertyname="hibernate.hbm2ddl.auto"value="update"/>

    另一种配置mysql的方法见 https://community.jboss.org/wiki/SetUpJBPM54FinalInstallerToUseMySQL-OrHowToRunSection37OfTheUserGuide



    转自: http://blog.csdn.net/haiyan2012/article/details/8881021

  • 0
    0

    查看评论
    * 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
      个人资料
      • 访问:337468次
      • 积分:4478
      • 等级:
      • 排名:第6882名
      • 原创:65篇
      • 转载:343篇
      • 译文:0篇
      • 评论:23条