activiti自定义流程之整合(一):整体环境配置
博客专区 > Yemon 的博客 > 博客详情
activiti自定义流程之整合(一):整体环境配置
Yemon 发表于2年前
activiti自定义流程之整合(一):整体环境配置
  • 发表于 2年前
  • 阅读 3
  • 收藏 0
  • 点赞 2
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

结合之前所说的自定义流程的思路,分别是后台、前台、整合,之前的内容也分别进行了相关的练习和尝试,现在就该到了最后的整合了,依旧是以实现功能为目的,细节暂且不去管他。


因为我们实际项目后端用的是spring、spring mvc、mysql、mybatis,前台用的angular js,因此在整合时我也自己搭建使用了这样的环境。


1、 所使用的环境基础:eclipse4.4、mysql5.6、angularjs1.4、tomcat7、jdk1.7、maven3.2、spring4.0.9、activiit5.16、activiti-modeler5.16


2、 后端maven导包pom.xml文件如下:
[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1.  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
  3.   <modelVersion>4.0.0</modelVersion>  
  4.   <groupId>activitiTest1</groupId>  
  5.   <artifactId>activitiTest1</artifactId>  
  6.   <packaging>war</packaging>  
  7.   <version>0.0.1-SNAPSHOT</version>  
  8.   <name>activitiTest1 Maven Webapp</name>  
  9.   <url>http://maven.apache.org</url>  
  10.   <dependencies>  
  11.     <dependency>  
  12.       <groupId>junit</groupId>  
  13.       <artifactId>junit</artifactId>  
  14.       <version>4.11</version>  
  15.     </dependency>  
  16.     <dependency>  
  17.         <groupId>org.springframework</groupId>  
  18.         <artifactId>spring-beans</artifactId>  
  19.         <version>4.0.9.RELEASE</version>  
  20.     </dependency>  
  21.     <dependency>  
  22.         <groupId>org.springframework</groupId>  
  23.         <artifactId>spring-core</artifactId>  
  24.         <version>4.0.9.RELEASE</version>  
  25.     </dependency>  
  26.     <dependency>  
  27.         <groupId>org.springframework</groupId>  
  28.         <artifactId>spring-aop</artifactId>  
  29.         <version>4.0.9.RELEASE</version>  
  30.     </dependency>  
  31.     <dependency>  
  32.         <groupId>org.springframework</groupId>  
  33.         <artifactId>spring-context</artifactId>  
  34.         <version>4.0.9.RELEASE</version>  
  35.     </dependency>  
  36.     <dependency>  
  37.         <groupId>org.springframework</groupId>  
  38.         <artifactId>spring-webmvc</artifactId>  
  39.         <version>4.0.9.RELEASE</version>  
  40.     </dependency>  
  41.     <dependency>  
  42.         <groupId>org.springframework</groupId>  
  43.         <artifactId>spring-web</artifactId>  
  44.         <version>4.0.9.RELEASE</version>  
  45.     </dependency>  
  46.     <dependency>  
  47.         <groupId>org.springframework</groupId>  
  48.         <artifactId>spring-aspects</artifactId>  
  49.         <version>4.0.9.RELEASE</version>  
  50.     </dependency>  
  51.     <dependency>  
  52.         <groupId>org.springframework</groupId>  
  53.         <artifactId>spring-expression</artifactId>  
  54.         <version>4.0.9.RELEASE</version>  
  55.     </dependency>  
  56.     <dependency>  
  57.         <groupId>org.springframework</groupId>  
  58.         <artifactId>spring-tx</artifactId>  
  59.         <version>4.0.9.RELEASE</version>  
  60.     </dependency>  
  61.     <dependency>  
  62.         <groupId>javax.servlet</groupId>  
  63.         <artifactId>javax.servlet-api</artifactId>  
  64.         <version>3.1.0</version>  
  65.     </dependency>  
  66.     <dependency>  
  67.         <groupId>com.fasterxml.jackson.core</groupId>  
  68.         <artifactId>jackson-annotations</artifactId>  
  69.         <version>2.2.3</version>  
  70.     </dependency>  
  71.     <dependency>  
  72.         <groupId>com.fasterxml.jackson.core</groupId>  
  73.         <artifactId>jackson-core</artifactId>  
  74.         <version>2.2.3</version>  
  75.     </dependency>  
  76.     <dependency>  
  77.         <groupId>com.fasterxml.jackson.core</groupId>  
  78.         <artifactId>jackson-databind</artifactId>  
  79.         <version>2.2.3</version>  
  80.     </dependency>  
  81.     <dependency>  
  82.         <groupId>org.activiti</groupId>  
  83.         <artifactId>activiti-modeler</artifactId>  
  84.         <version>5.16</version>  
  85.     </dependency>  
  86.     <dependency>  
  87.         <groupId>org.activiti</groupId>  
  88.         <artifactId>activiti-engine</artifactId>  
  89.         <version>5.16</version>  
  90.     </dependency>  
  91.     <dependency>  
  92.         <groupId>org.activiti</groupId>  
  93.         <artifactId>activiti-explorer</artifactId>  
  94.         <version>5.16</version>  
  95.     </dependency>  
  96.     <dependency>  
  97.         <groupId>org.activiti</groupId>  
  98.         <artifactId>activiti-rest</artifactId>  
  99.         <version>5.16</version>  
  100.     </dependency>  
  101.     <dependency>  
  102.         <groupId>org.springframework</groupId>  
  103.         <artifactId>spring-context-support</artifactId>  
  104.         <version>4.0.9.RELEASE</version>  
  105.     </dependency>  
  106.     <dependency>  
  107.         <groupId>mysql</groupId>  
  108.         <artifactId>mysql-connector-java</artifactId>  
  109.         <version>5.1.34</version>  
  110.     </dependency>  
  111.   
  112.   
  113.     <dependency>  
  114.         <groupId>org.activiti</groupId>  
  115.         <artifactId>activiti-spring</artifactId>  
  116.         <version>5.16</version>  
  117.     </dependency>  
  118.     <dependency>  
  119.         <groupId>org.springframework</groupId>  
  120.         <artifactId>spring-jdbc</artifactId>  
  121.         <version>4.0.9.RELEASE</version>  
  122.     </dependency>  
  123.     <dependency>  
  124.         <groupId>org.springframework</groupId>  
  125.         <artifactId>spring-test</artifactId>  
  126.         <version>4.0.9.RELEASE</version>  
  127.     </dependency>  
  128.     <dependency>  
  129.         <groupId>org.activiti</groupId>  
  130.         <artifactId>activiti-bpmn-converter</artifactId>  
  131.         <version>5.16</version>  
  132.     </dependency>  
  133.     <dependency>  
  134.         <groupId>org.codehaus.jackson</groupId>  
  135.         <artifactId>jackson-core-asl</artifactId>  
  136.         <version>1.9.11</version>  
  137.     </dependency>  
  138.     <dependency>  
  139.         <groupId>org.codehaus.jackson</groupId>  
  140.         <artifactId>jackson-mapper-asl</artifactId>  
  141.         <version>1.9.11</version>  
  142.     </dependency>  
  143.   </dependencies>  
  144.   <build>  
  145.     <finalName>activitiTest1</finalName>  
  146.   </build>  
  147. </project>  


3、 web项目基础配置web.xml如下:
[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3. xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  
  5. id="WebApp_ID" version="2.5">      
  6. <filter>  
  7.     <description>字符集过滤器</description>  
  8.     <filter-name>encodingFilter</filter-name>  
  9.     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
  10.     <init-param>  
  11.         <description>字符集编码</description>  
  12.         <param-name>encoding</param-name>  
  13.         <param-value>UTF-8</param-value>  
  14.     </init-param>  
  15. </filter>  
  16. <filter-mapping>  
  17.     <filter-name>encodingFilter</filter-name>  
  18.     <url-pattern>/*</url-pattern>  
  19. </filter-mapping>  
  20.   
  21.   
  22. <servlet>  
  23.    <servlet-name>RestletServlet</servlet-name>  
  24.    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>  
  25.    <init-param>  
  26.      <param-name>org.restlet.application</param-name>  
  27.      <param-value>org.activiti.rest.editor.application.ModelerRestApplication</param-value>  
  28.    </init-param>  
  29.  </servlet>  
  30.  <servlet-mapping>  
  31.    <servlet-name>RestletServlet</servlet-name>  
  32.    <url-pattern>/service/*</url-pattern>  
  33.  </servlet-mapping>  
  34.   
  35.   
  36.    <servlet>    
  37.        <servlet-name>springMVC</servlet-name>    
  38.        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>    
  39.        <init-param>    
  40.            <param-name>contextConfigLocation</param-name>    
  41.            <param-value>classpath:spring.xml</param-value>    
  42.        </init-param>      
  43.    </servlet>    
  44.    <servlet-mapping>    
  45.        <servlet-name>springMVC</servlet-name>    
  46.        <url-pattern>*.do</url-pattern>    
  47.    </servlet-mapping>  
  48.    <welcome-file-list>  
  49.     <welcome-file>activiti.html</welcome-file>  
  50.     <welcome-file>activiti.htm</welcome-file>  
  51.     <welcome-file>activiti.jsp</welcome-file>  
  52.     <welcome-file>default.html</welcome-file>  
  53.     <welcome-file>default.htm</welcome-file>  
  54.     <welcome-file>default.jsp</welcome-file>  
  55.    </welcome-file-list>    
  56. lt;/web-app>    


4、 其他依赖环境,如下图中红线框起来的部分:其中包括使用angularjs依赖的js,整合activiti-modeler依赖的文件和使用ueditor插件所需的文件。(具体的文件可参考之前的博客内容)



5、后台spring基础配置文件spring.xml如下:

   
[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>    
  2. lt;beans xmlns="http://www.springframework.org/schema/beans"    
  3.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"    
  4.    xmlns:context="http://www.springframework.org/schema/context"    
  5.    xmlns:mvc="http://www.springframework.org/schema/mvc"      
  6.    xsi:schemaLocation="    
  7.        http://www.springframework.org/schema/beans     
  8.        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd    
  9.        http://www.springframework.org/schema/context     
  10.        http://www.springframework.org/schema/context/spring-context-3.0.xsd  
  11.        http://www.springframework.org/schema/mvc   
  12.        http://www.springframework.org/schema/mvc/spring-mvc.xsd">    
  13.   
  14.   
  15.    <context:annotation-config />    
  16.    <mvc:annotation-driven />  
  17.    <context:component-scan base-package="controllers" />    
  18.    <context:component-scan base-package="serviceImp" />  
  19. <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">  
  20.      
  21.    <property name="driverClass" value="com.mysql.jdbc.Driver"></property>  
  22.    <property name="url" value="jdbc:mysql://127.0.0.1:3306/testtu?useUnicode=true&characterEncoding=utf8" ></property>  
  23.    <property name="username" value="root" ></property>   
  24.    <property name="password" value="123456" ></property>   
  25. </bean>  
  26.   
  27. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  28.    <property name="dataSource" ref="dataSource"></property>  
  29. </bean>  
  30.   
  31. <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">  
  32.        <property name="dataSource" ref="dataSource" />  
  33.     <property name="databaseSchemaUpdate" value="true" />  
  34.     <property name="jobExecutorActivate" value="false"/>  
  35.     <property name="history" value="full"/>  
  36.     <property name="transactionManager" ref="transactionManager" />  
  37.     <!-- 配置事务管理器,统一事务 -->  
  38.       
  39.     <!-- 设置建表策略,如果没有表,自动创建表 -->  
  40. </bean>  
  41. <!-- 创建流程引擎对象 -->  
  42. <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">  
  43.     <property name="processEngineConfiguration" ref="processEngineConfiguration" />  
  44. </bean>  
  45.   
  46.   
  47. <!-- 由流程引擎对象,提供的方法,创建项目中使用的Activiti工作流的Service -->  
  48. <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />  
  49. <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />  
  50. <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />  
  51. <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />  
  52. <bean id="formService" factory-bean="processEngine" factory-method="getFormService" />  
  53.     <bean id="IdentityService" factory-bean="processEngine" factory-method="getIdentityService" />  
  54.    <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->  
  55. <bean id="mappingJacksonHttpMessageConverter"  
  56.     class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">  
  57.     <property name="supportedMediaTypes">  
  58.         <list>  
  59.             <value>text/html;charset=utf-8</value>  
  60.         </list>  
  61.     </property>  
  62. </bean>  
  63.   
  64.   
  65. <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->  
  66. <bean  
  67.     class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
  68.     <property name="messageConverters">  
  69.         <list>  
  70.             <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->  
  71.         </list>  
  72.     </property>  
  73. </bean>  
  74.      
  75. lt;/beans>    


5、 整个项目结构如图:

共有 人打赏支持
粉丝 11
博文 320
码字总数 22799
×
Yemon
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: