ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

flowable实战(一)flowable与spring boot集成

2021-06-02 13:56:32  阅读:285  来源: 互联网

标签:flowable spring boot springframework poi org com


(一)只需要在pom.xml配置好以下(加粗部分):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.zjm</groupId>
   <artifactId>gwork</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>gwork</name>
   <description>gwork project for  Spring Boot</description>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.4.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      <flowable.version>6.4.1</flowable.version>
      <mysql.version>5.1.46</mysql.version>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
         <exclusions>
            <exclusion>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <!--日志配置 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

      <dependency>
         <groupId>org.mybatis.spring.boot</groupId>
         <artifactId>mybatis-spring-boot-starter</artifactId>
         <version>1.3.2</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-configuration-processor</artifactId>
         <optional>true</optional>
      </dependency>
      <!--flowable  set -->
      <dependency>
         <groupId>org.flowable</groupId>
         <artifactId>flowable-spring-boot-starter</artifactId>
         <version>${flowable.version}</version>
      </dependency>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>${mysql.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>    
     
      <!--======以下依赖内容为zhongzk 增加  begin========== -->      
      <!--  spring security 和 jwt -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
          <groupId>io.jsonwebtoken</groupId>
          <artifactId>jjwt</artifactId>
          <version>0.9.1</version>
        </dependency>
      
      
      <dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-core</artifactId>
      </dependency>
      <dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-databind</artifactId>
      </dependency>
      <dependency>
         <groupId>com.fasterxml.jackson.datatype</groupId>
         <artifactId>jackson-datatype-joda</artifactId>
      </dependency>
      <dependency>
         <groupId>com.fasterxml.jackson.module</groupId>
         <artifactId>jackson-module-parameter-names</artifactId>
      </dependency>
      <!-- 分页插件 -->
      <dependency>
         <groupId>com.github.pagehelper</groupId>
         <artifactId>pagehelper-spring-boot-starter</artifactId>
         <version>1.2.5</version>
      </dependency>
      <!-- alibaba的druid 数据库连接池 -->
      <dependency>
         <groupId>com.alibaba</groupId>
         <artifactId>druid-spring-boot-starter</artifactId>
         <version>1.1.9</version>
      </dependency>
      
      <!-- javax.servlet-api -->
        <dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>javax.servlet-api</artifactId>
           <scope>provided</scope>
        </dependency>
        
       <!-- mockmaker 依赖 -->
       <dependency>
           <groupId>net.bytebuddy</groupId>
           <artifactId>byte-buddy</artifactId>
       </dependency>
       <dependency>
           <groupId>net.bytebuddy</groupId>
           <artifactId>byte-buddy-agent</artifactId>
           <scope>test</scope>
       </dependency>

      <!-- mybatis-generator-maven-plugin 插件2010.4.1 zhongzk -->
      <dependency>
         <groupId>org.mybatis.generator</groupId>
         <artifactId>mybatis-generator-maven-plugin</artifactId>
         <version>1.3.7</version>
      </dependency>

      <!-- poi  开源包zhongzk 2019.4.6-->
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi</artifactId>
         <version>3.17</version>
      </dependency>
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-examples</artifactId>
         <version>3.17</version>
      </dependency>
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-excelant</artifactId>
         <version>3.17</version>
      </dependency>
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId> poi-scratchpad</artifactId>
         <version>3.17</version>
      </dependency>
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-ooxml</artifactId>
         <version>3.17</version>
      </dependency>
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-ooxml-schemas</artifactId>
         <version>3.17</version>
      </dependency>

      <!-- common csv zhongzk 2019.4.6  -->
      <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-csv</artifactId>
         <version>1.6</version>
      </dependency>

    

      <!--=====依赖内容为zhongzk 增加   end==== -->
   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
            <!-- zhongzk 2010.4.1 mybatis-generator插件-->
         <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.3.2</version>
            <configuration>
               <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
               <verbose>true</verbose>
               <overwrite>true</overwrite>
            </configuration>
            <executions>
               <execution>
                  <id>Generate MyBatis Artifacts</id>
                  <goals>
                     <goal>generate</goal>
                  </goals>
               </execution>
            </executions>
            <dependencies>
               <dependency>
                  <groupId>org.mybatis.generator</groupId>
                  <artifactId>mybatis-generator-core</artifactId>
                  <version>1.3.2</version>
               </dependency>
            </dependencies>
         </plugin>

      </plugins>
      <resources>
         <resource>
            <directory>src/main/java</directory>
            <includes>
               <include>**/*.xml</include>
            </includes>
         </resource>
      </resources>
   </build>


</project>

(二)在spring boot主main类中,关掉spring security认证以及配置Mapper接口的扫描:

package com.zjm.gwork;

import javax.servlet.MultipartConfigElement;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import java.io.File;

@SpringBootApplication
//添加对mapper包扫描
@MapperScan("com.zjm.gwork.**.mapper")
//过滤器开关
@ServletComponentScan("com.zjm.gwork.utils")
//取消spring security的认证
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
//开启缓存功能
//@EnableCaching
//启动swagger注解
public class GworkApplication {

   public static void main(String[] args) {
      SpringApplication.run(GworkApplication.class, args);
      
      
   }
   /**  
     * 文件上传配置 zhongzk
     * @return  
     */  
    @Bean  
    public MultipartConfigElement multipartConfigElement() {  
        MultipartConfigFactory factory = new MultipartConfigFactory();  
        //单个文件最大  
        factory.setMaxFileSize("300MB"); //KB,MB  
        // 设置总上传数据总大小
        factory.setMaxRequestSize("500MB");
        // 临时文件路径
        String tempUrl = System.getProperty("user.dir") + File.separator + "bjgwork" +  File.separator + "tmp";
        System.out.println("临时目录:" + tempUrl);
        File file = new File(tempUrl);
        if (!file.exists()) {
            file.mkdirs();
        }
        factory.setLocation(tempUrl);
        return factory.createMultipartConfig();  
    }  
}

(三)application.yml配置好数据库的连接池,如下:

server:
  port: 7001


spring:
    datasource:
        #基本属性
        url: jdbc:mysql://localhost:3306/gwork?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
        username: root
        password: root
        
        #druid相关配置
        druid:
          #监控统计拦截的filters
          filters: stat
          driver-class-name: com.mysql.jdbc.Driver                 
          #配置初始化大小/最小/最大
          initial-size: 2
          min-idle: 2
          max-active: 30
          #获取连接等待超时时间
          max-wait: 60000
          #间隔多久进行一次检测,检测需要关闭的空闲连接
          time-between-eviction-runs-millis: 60000
          #一个连接在池中最小生存的时间
          min-evictable-idle-time-millis: 300000
          validation-query: SELECT 'x'
          test-while-idle: true
          test-on-borrow: false
          test-on-return: false
          #打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
          pool-prepared-statements: false
          max-pool-prepared-statement-per-connection-size: 20


    #上传附件的目录设置以及系统一块模板word、excel的存放路径 zhongzk 2019.4.8
    #这样做的原因是由于spring boot发布时打包成了jar,所以没有办法往jar中写文件
    filepath:
        uploadpath: c:\uploadfile\
        templatepath: c:\templatefile\


mybatis:
  #mapper-locations: classpath:mapper/*.xml
  mapper-locations: classpath*:com/zjm/gwork/**/mapper/*mapper.xml
  #type-aliases-package: com.zjm.gwork.model
  type-aliases-package: com.zjm.gwork.**.model



#pagehelper
pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql
    returnPageInfo: check

#flowable 取消spring boot时自动部署resource/processes中的流程文件
flowable:
  check-process-definitions: false
  #db-identity-used: true
  # 自动生成flowable相关表 第一次生成后建议关闭提高运行速度
  database-schema-update: true
  # 保存历史数据级别设置为full最高级别,便于历史数据的追溯
  history-level: full


(四)启动spring boot后自动生成70张数据库表,建议安装JRebel:秒级热更新神器必备。

本项目的真实开发环境是前端node+vue,后端spring boot+mybatis+mysql5.6,采用git版本管理,码云做敏捷开发管理,swagger用于api注释用法文档自动生成。


 

标签:flowable,spring,boot,springframework,poi,org,com
来源: https://blog.51cto.com/u_10976476/2845656

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有