flowable与spring boot集成

一)只需要在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/>
</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>
  </dependencies>
  <build>
  <plugins>
     <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
     </plugin>
     <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注释用法文档自动生成。

————————————————
版权声明:本文为优快云博主「热水钟」的原创文章,遵循CC 4.0 by-sa版权协议.
原文链接:https://blog.youkuaiyun.com/zhongzk69/article/details/90735864

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值