插曲二 转网上介绍的另一篇“JBPM用sqlserver数据库”

来源:互联网 发布:windows dhcp服务器 编辑:程序博客网 时间:2024/06/13 13:41

1.        源代码:先到主站(http://www.jboss.com/products/jbpm/downloads)上下载JBPM的源代码(jbpm-3.1.1.zip),也可以从cvs里同步代码,本人采用的是jbpm-3.1.1版本.

2.        应用服务器:本人采用的是JBOSS4.04,jdk1.5

3.        数据库:采用的是MSSQL server2000,启动企业管理器,建一个库,:jbpmtest.

4.        项目配置:先把下载下来的源代码zip包解压,eclipse里导入jbpm-3.1.1源代码.

5.        修改配置文件:

a)       新建文件夹,用于存放数据库相关配置.src/resources目下建立一个新文件夹:mssql.

b)       拷贝文件:将同目录下的hsqldb的两个文件(/hsqldb/create.db.hibernate.properties/hsqldb/identity.db.xml)拷贝到新建的文件夹里.

c)       修改文件:

d)       create.db.hibernate.properties.此文件主要是数据库连接属性配置,:

hibernate.dialect= org.hibernate.dialect.SQLServerDialect

hibernate.connection.driver_class=

net.sourceforge.jtds.jdbc.Driver

hibernate.connection.url= jdbc:jtds:sqlserver://localhost:1433/jbpmtest

hibernate.connection.username=sa

hibernate.connection.password=123456

hibernate.show_sql=true

e)       src/config.files/hibernate.cfg.xml.此文件主要是系统运行时数据库连接属性配置,:

<!-- jdbc connection properties -->

<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

<property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:1433/jbpmtest</property>

<property name="hibernate.connection.username">sa</property>

<property name="hibernate.connection.password">123456</property>

 

f)       项目根目录下的build.deploy.xml.

1.       找到create.db节点,修改为:

<!-- ============== -->

<!-- === SERVER === -->

<!-- ============== -->

<target name="create.db" depends="declare.jbpm.tasks, db.clean, db.start" description="creates a hypersonic database with the jbpm tables and loads the processes in there">

<jbpmschema actions="create"

cfg="${basedir}/src/config.files/hibernate.cfg.xml"

properties="${basedir}/src/resources/mssql/create.db.hibernate.properties"/>

<loadidentities file="${basedir}/src/resources/mssql/identity.db.xml"

cfg="${basedir}/src/config.files/hibernate.cfg.xml"

properties="${basedir}/src/resources/mssql/create.db.hibernate.properties"/>

<ant antfile="build.xml" target="build.processes" inheritall="false" />

<deployprocess cfg="${basedir}/src/config.files/hibernate.cfg.xml"

properties="${basedir}/src/resources/mssql/create.db.hibernate.properties">

<fileset dir="build" includes="*.process" />

</deployprocess>

<antcall target="db.stop" />

</target>

2.       找到deploy.processes节点

<target name="deploy.processes" depends="declare.jbpm.tasks" description="deploys the jbpm processes">

<ant antfile="build.xml" target="build.processes" inheritall="false" />

<deployprocess cfg="src/config.files/hibernate.cfg.xml"

properties="${basedir}/src/resources/mssql/create.db.hibernate.properties">

<fileset dir="build" includes="*.process" />

</deployprocess>

</target>

6.        sqlserver的驱动放到根目录下的lib目录里

7.        修改根部目下的build.properties文件,主要是jboss的位置

8.        运行ant生成必要的数据库表和库文件.

a)       运行ant构建器,在控制台能看到日志信息,可以看到数据库脚本等等信息.生成的jar文件都在根目的build目录下.如果你什么地方没有修改好的话,可能会有错误信息,按照日志查看原因

9.        将几个jar包拷贝到jbpm.war包的jbpm.war/WEB-INF/lib/目录下,还需要拷贝其他的库文件到此目录下(包括jdbc的驱动程序等).具体可用参考一下项目根目录下的lib.

注意:如果部署到jboss下,可以copy  jbpm.war.dir然后改名为jbpm.war

10.     结束

备注:其他的数据库方法是一样的,只要是Hibernate支持的数据库,都可以。如果再次用ant构建时,最好把你第一次构建的删除掉

原创粉丝点击