Springboot 2.0+activiti 7 Integration--Initial knowledge of activiti and database creation

Posted by wolfan on Thu, 21 Nov 2019 09:37:14 +0100

1. Initial Actiti

Because of recent project requirements requiring the use of processes, the active process framework has been chosen. Most of the integration of springboot version 2.0 and activiti6.0 is online. Since the project already uses springboot 2.0, the process of integrating activiti7 is recorded.

Personal impression of activiti:

1.Actiti itself is a relatively complete application that includes databases, API s, and front-ends; ** It runs independently and can be referred to in detail as [activiti 6.0](https://www.activiti.org/get-started) for three applications activiti-admin.war, activiti-app.war, activiti-rest.war (don't ask me why not say 7.0, because I can't find a 7.0 related document on the official website, the opposite of 6.0)And very complete)

2. Actiti is just a process framework; ** With regard to the integration of the original project with activiti, the general idea now is to use the activiti interface to create and manage processes, or to have specific content in the database you created.

2. Create an activiti database

 Start using it now, run first and then say:

2.1 pom.xml

springboot version: 2.2.1.RELEASE 
Actiti version: 7.1.0.M1
 mysql version: 5.1.30 (critical)

Specific code:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>activiti-demo2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>activiti-demo2</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-spring-boot-starter</artifactId>
            <version>7.1.0.M1</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
<!--            <scope>runtime</scope>-->
            <version>5.1.30</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

2.2 Create activiti.cfg.xml file

Create activiti.cfg.xml under the resources file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <property name="databaseType" value="mysql"></property>
        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti"></property>
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
        <property name="jdbcUsername" value="root"></property>
        <property name="jdbcPassword" value="123456"></property>
    </bean>
</beans>

2.3 Create an activiti database

You need to create a database named "activiti" in the mysql database first

2.4 Create main function

package com.example.activitidemo2;

import org.activiti.engine.impl.db.DbSchemaCreate;

/**
 * @Description: test
 * @Author: zx
 * @Time: 2019-11-20 09:25
 **/
public class Test {

    public static void main(String[] args) {
        DbSchemaCreate.main(args);
    }
}
Run main function

2.5 Created Successfully

Database table description:
ACT_RE_*: RE denotes repository, a static resource for a stored process, such as a process model file, etc.
ACT_RU_*: RU stands for runtime, which stores data generated by the activiti runtime, such as instance information, user task information, job information, etc. In addition, when the process is completed, runtime data will be deleted to ensure the minimum amount of data and performance.
ACT_ID_*: ID denotes identity and stores authentication information such as users, groups, etc.
ACT_HI_*: HI denotes history, stores process history data, such as instance information, variable data, and so on.
ACT_GE_*: GE means general and stores common data.

There are only 25 tables. (Actiti7 has no tables with ID classes, does not affect integration, and does not want an identity section at all) (Actiti6 is 28)

3. Trampled pits

3.1 Springboot and activiti version issues

Springboot above 2.0 is recommended to use activiti7.0, otherwise you may encounter many version problems, activiti6 at the time springboot 2.0 has not yet been released.

3.2 mysql and activiti version issues

You must not use the com.mysql.cj.jdbc.Driver driver when generating database tables because activiti only supports com.mysql.jdbc.Driver for the time being, so you need to reduce the version of mysql.
bug:

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
    at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
    at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2121)
    at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2145)
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
    ... 30 more

Reference website:

https://segmentfault.com/a/1190000020288808

Topics: Java MySQL Spring JDBC