1.web.xml文件
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/springContext-jbpm.xml </param-value> </context-param>
2. springContext-jbpm.xml文件
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/jbpm?characterEncoding=utf-8</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mappingDirectoryLocations"> <list> <value>classpath*:/org/jbpm/**/*.hbm.xml</value> </list> </property>
<!-- 以下为JAR 包部署路径-->
<property name="mappingJarLocations"> <list> <value>WEB-INF/lib/jbpm-3.0.1.jar</value> <value>WEB-INF/lib/jbpm-identity-3.0.1.jar</value> </list> </property>
<property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">none</prop> </props> </property> </bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean>
<bean id="processDefinition" class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
<property name="definitionLocation" value="processdefinition.xml"/>
</bean>
<bean id="jbpmConfiguration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="configuration" value="jbpm.cfg.xml"/>
<property name="processDefinitions">
<list>
<ref local="processDefinition"/>
</list>
</property>
<property name="createSchema" value="true"/>
</bean>
<bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<property name="jbpmConfiguration" ref="jbpmConfiguration"/>
</bean>
在代码中注入jbpmTemplate,就可以了:
private JbpmTemplate jbpmTemplate = null;
public void setJbpmTemplate(JbpmTemplate jbpmTemplate) {
this.jbpmTemplate = jbpmTemplate;
}