1.引入jar包,完整pom文件
<?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.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>Activity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Activity</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-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>5.22.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>5.22.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2.application.properties文件
#编码格式
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
#activiti
#自动检查、部署流程定义文件
spring.activiti.check-process-definitions=true
#自动更新数据库结构
spring.activiti.database-schema-update=true
#流程定义文件存放目录
spring.activiti.process-definition-location-prefix=classpath:/processes/
#流程文件格式
spring.activiti.process-definition-location-suffixes=
#数据库连接
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
3.启动类
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class ActivityApplication {
public static void main(String[] args) {
SpringApplication.run(ActivityApplication.class, args);
}
}
4.遇到的问题
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.activiti.spring.boot.SecurityAutoConfiguration’: Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
去掉org.activiti.spring.boot.SecurityAutoConfiguration类,如下图
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
- class path resource [processes/] cannot be resolved to URL because it does not exist
将spring.activiti.check-process-definitions=false改为false,或者在resource下创建processes文件夹 - Caused by: java.sql.SQLSyntaxErrorException: Table ‘activiti.act_ge_property’ doesn’t exist
添加
nullCatalogMeansCurrent=true
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
- nested exception is java.lang.NoClassDefFoundError: javax/el/ELResolver
activiti jar包要保持一致