环境配置
项目环境:
JDK1.8
tomcat7
maven3.5
开发工具:
IDEA
activiti7
创建项目
目标:创建一个maven项目,集成Activiti,并自动生成25张数据库表
准备工作
在数据库中运行:
CREATE DATABASE activiti DEFAULT CHARACTER SET utf8;
用于创建Activiti数据库
在项目中会使用到BPMN图形,所以要先安装actiBPM插件,安装方法如下:
在IDEA中实用快捷键Shift+Ctrl+Alt+S打开环境中心
新建一个maven项目
1.点击new Project创建一个新项目
2.选择maven项目创建
3.填写项目信息
4.设置maven信息
5.点击flsh完成项目创建,创建结构如下
6.补全项目中main文件夹下的java,resource等源文件夹
在IDEA中实用快捷键Shift+Ctrl+Alt+S打开环境中心,选择main包,右键new folder依次新建缺少的文件夹
7.创建完成后与对应文件源一一点击对应
8.在resources包下创建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"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://192.168.0.114:3306/activiti"/> <property name="username" value="root"/> <property name="password" value="123456"/> </bean> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> <property name="dataSource" ref="dataSource"></property> <property name="databaseSchemaUpdate" value="true"/> </bean> </beans>
9.在resources包下创建log4j.properties
代码如下
# Set root category priority to INFO and its only appender to CONSOLE. #log4j.rootCategory=INFO, CONSOLE debug info warn error fatal log4j.rootCategory=debug, CONSOLE, LOGFILE # Set the enterprise logger category to FATAL and its only appender to CONSOLE. log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m # LOGFILE is set to be a File appender using a PatternLayout. log4j.appender.LOGFILE=org.apache.log4j.FileAppender log4j.appender.LOGFILE.File=/Users/apple/学习/study/activity/activity_01/xis.log log4j.appender.LOGFILE.Append=true log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m 9.在test包下创建测试类,生成数据库表文件 import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngineConfiguration; import org.activiti.engine.ProcessEngines; import org.junit.Test; /** * @author : YXC * @version : 1.0 * @description : * @date : 2020/11/17 16:50 */ public class ActivitiTest { @Test public void testGenTable(){ //1.创建ProcessEngineConfiguration对象 ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml"); //2.创建ProcessEngine对象 ProcessEngine processEngine = configuration.buildProcessEngine(); System.out.println(processEngine); } @Test public void testGenTable2(){ //使用下面这种方式生成表的条件 //1.activiti配置文件名称必须为activiti.cfg.xml //2.bean的id必须为"processEngineConfiguration" ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine(); System.out.println(defaultProcessEngine); } }
10.生成表结构如下
Java 的知识面非常广,面试问的涉及也非常广泛,重点包括:Java 基础、Java 并发,JVM、MySQL、数据结构、算法、Spring、微服务、MQ 等等,涉及的知识点何其庞大,所以我们在复习的时候也往往无从下手,今天小编给大家带来一套 Java 面试题,题库非常全面,包括 Java 基础、Java 集合、JVM、Java 并发、Spring全家桶、Redis、MySQL、Dubbo、Netty、MQ 等等,包含 Java 后端知识点 2000 + ,部分如下:
资料获取方式:关注公众号:“程序员白楠楠”获取上述资料