欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

activiti7-1-环境准备(idea)

程序员文章站 2022-10-03 09:36:49
activiti7环境准备1.首先安装插件2.然后建库3.pom4.配置文件4.1 log4j.properties4.2 activiti.cfg.xml5.测试类生成表6.目录结构7.最后的操作(务必看一看)为了方便,使用idea进行学习,eclipse的自行搜索了 也差不多的。下面建个maven工程就行(别说你不会建maven工程-_-!),然后单纯学activiti,就不整合springboot了,所以莫得yaml,而是有一堆配置文件,如果觉得这几个配置文件看着不舒服的,自行百度springb...

又回到csdn了,今年一直在使用有道云笔记,后面发现有道云还是有很多缺陷,不能满足我,故而重归csdn,好,回归之第一系列activiti献上。为了方便,使用idea进行学习,eclipse的自行搜索了 也差不多的。下面建个maven工程就行(别说你不会建maven工程-_-!),然后单纯学activiti,就不整合springboot了,所以莫得yaml,而是有一堆配置文件,如果觉得这几个配置文件看着不舒服的,自行百度springboot整合activiti

1.首先安装插件

actiBPM这个插件
activiti7-1-环境准备(idea)
我图上是已经安装好了,没有安装的应该在Browse repositories那个位置去找然后点install然后重启完事。这里不过多赘述。

2.然后建库

activiti7-1-环境准备(idea)
这里就单纯建个空的库就行了,表下面会用代码建。

3.pom

<properties>
    <slf4j.version>1.6.6</slf4j.version>
    <log4j.version>1.2.12</log4j.version>
</properties>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-engine -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-engine</artifactId>
        <version>7.1.0.M6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-spring -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring</artifactId>
        <version>7.1.0.M6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-bpmn-model -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-bpmn-model</artifactId>
        <version>7.1.0.M6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-bpmn-converter -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-bpmn-converter</artifactId>
        <version>7.1.0.M6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-json-converter -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-json-converter</artifactId>
        <version>7-201802-EA</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti/activiti-bpmn-layout -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-bpmn-layout</artifactId>
        <version>7.1.0.M6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.activiti.cloud/activiti-cloud-services-api -->
    <dependency>
        <groupId>org.activiti.cloud</groupId>
        <artifactId>activiti-cloud-services-api</artifactId>
        <version>7-201710-EA</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.40</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.4.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>alfresco</id>
        <name>Activiti Releases</name>
        <url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

4.配置文件

4.1 log4j.properties

### set log levels ###
log4j.rootLogger = DEBUG , C , D , E 

### console ###
log4j.appender.C = org.apache.log4j.ConsoleAppender
log4j.appender.C.Target = System.out
log4j.appender.C.layout = org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern = [mybatis_study][%p] [%-d{yyyy-MM-dd HH\:mm\:ss}] %C.%M(%L) | %m%n

### log file ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = ../logs/mybatis_study.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = INFO 
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = [mybatis_study][%p] [%-d{yyyy-MM-dd HH\:mm\:ss}] %C.%M(%L) | %m%n

### exception ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File = ../logs/axis.log 
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR 
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = [mybatis_study][%p] [%-d{yyyy-MM-dd HH\:mm\:ss}] %C.%M(%L) | %m%n

###mybatis show sql###
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug

log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug

4.2 activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                  http://www.springframework.org/schema/contex http://www.springframework.org/schema/context/spring-context.xsd
                  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--数据源配置dbcp-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
        <property name="username" value="xcw" />
        <property name="password" value="15186974221" />
    </bean>
    <!--activiti单独运行的ProcessEngine配置对象(processEngineConfiguration),使用单独启动方式
        默认情况下:bean的id=processEngineConfiguration
    -->

    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <!--代表数据源-->
        <property name="dataSource" ref="dataSource"></property>


        <!-- <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti" />
         <property name="jdbcUsername" value="root" />
         <property name="jdbcPassword" value="root" />-->
        <!--代表是否生成表结构-->
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>
</beans>

5.测试类生成表

@Test
public void testGenTable(){
    //1.创建ProcessEngineConfiguration
    ProcessEngineConfiguration configuration = ProcessEngineConfiguration
            .createProcessEngineConfigurationFromResource("activiti.cfg.xml");
    //2.创建ProcessEngine
    ProcessEngine processEngine = configuration.buildProcessEngine();

    //3.输出ProcessEngine对象
    System.out.println(processEngine);
}

然后运行即可.
在cfg文件中,默认情况下,bean的id=processEngineconfiguration
其实.createProcessEngineConfigurationFromResource(“activiti.cfg.xml”)这个方法第二个参数就是bean的id名称

6.目录结构

activiti7-1-环境准备(idea)

7.最后的操作(务必看一看)

理论上通过插件完成bpmn文件的绘制即可
注意:绘制bpmn文件之前,先打开idea的安装目录的bin目录下面
然后打开对应的vmoptions文件,在其尾部加上:

-Dfile.encoding=UTF-8

activiti7-1-环境准备(idea)
加完重启一下idea就搭建好了activitie7的初始环境了。

本文地址:https://blog.csdn.net/qq_38871652/article/details/110792248