SpringBoot整合Activiti學習(一)
前言
只有學到手的才是自己的,加油,boy!!!
環境
JDK版本 | JAVA version "1.8.0_212" |
---|---|
IDEA | 2020.1 |
SpringBoot | 2.3.2.RELEASE |
activiti-spring-boot-starter | 7.1.0.M5 |
搭建
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.code</groupId>
<artifactId>activiti_demo</artifactId>
<version>1.0-SNAPSHOT</version>
<description>
本節主要在於學習activiti, 話不多說, 肝就完事
</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring.boot.version>2.3.2.RELEASE</spring.boot.version>
<activiti.version>7.1.0.M1</activiti.version>
</properties>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>${activiti.version}</version>
</dependency>
<!--web操作-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--驅動-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--測試-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--mybatis-->
<!--<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
yml配置
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:///activiti?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
# activiti配置
activiti:
history-level: full
db-history-used: true
database-schema-update: true
注意: 因為activiti整合了security,因此需要加上部分程式碼,這段程式碼可以在官方例子程式碼中找到
@Component
public class SecurityUtil {
private Logger logger = LoggerFactory.getLogger(SecurityUtil.class);
@Autowired
private UserDetailsService userDetailsService;
public void logInAs(final String username) {
final UserDetails user = userDetailsService.loadUserByUsername(username);
if (user == null) {
throw new IllegalStateException("User " + username + " doesn't exist, please provide a valid user");
}
logger.info("> Logged in as: " + username);
SecurityContextHolder.setContext(new SecurityContextImpl(new Authentication() {
public Collection<? extends GrantedAuthority> getAuthorities() {
return user.getAuthorities();
}
public Object getCredentials() {
return user.getPassword();
}
public Object getDetails() {
return user;
}
public Object getPrincipal() {
return user;
}
public boolean isAuthenticated() {
return true;
}
public void setAuthenticated(boolean b) throws IllegalArgumentException {
}
public String getName() {
return user.getUsername();
}
}));
org.activiti.engine.impl.identity.Authentication.setAuthenticatedUserId(username);
}
}
到此基本算是搭建完成...
執行專案,會生成如下25張表
act_evt_log -- 估計是日誌一類的
act_ge_* -- 是儲存部署的資源的,下一篇我們就可以看到
act_hi_* --是歷史一類的,在yml裡面配置之後才會生成歷史相關的表
act_ru_* -- 不用說了,例項執行一類的相關記錄表
相關文章
- activiti-study 整合 學習
- springboot 整合 activiti 流程引擎Spring Boot
- activiti整合springboot的一個怪問題Spring Boot
- SpringBoot整合Activiti7使用Spring Boot
- SpringBoot學習之整合MybatisSpring BootMyBatis
- Rabbit學習---SpringBoot整合RabbitMQSpring BootMQ
- SpringBoot學習之整合AOPSpring Boot
- 整合學習(一):簡述整合學習
- activiti學習記錄
- Elasticsearch學習<四>SpringBoot整合esElasticsearchSpring Boot
- 個人學習系列 - SpringBoot整合RabbitMQSpring BootMQ
- Elasticsearch學習(三)springboot整合ElasticSearchElasticsearchSpring Boot
- Activiti 學習(三)—— Activiti 流程啟動並完成
- 【springboot】學習4:整合JDBC、整合druid、整合mybatis、整合 SpringSecuritySpring BootJDBCUIMyBatisGse
- activiti學習筆記二筆記
- SpringBoot學習之整合SwaggerSpring BootSwagger
- Activiti學習筆記一:建立資料庫表筆記資料庫
- activiti學習筆記(四)managementService筆記
- Activiti 學習筆記 小結筆記
- Activiti配置整合到nacos
- Activiti 學習筆記一到六小結筆記
- SpringBoot整合ElasticSearch 入門demo學習筆記Spring BootElasticsearch筆記
- Activiti 學習筆記七:連線(SequenceFlow)筆記
- Activiti 學習筆記五:流程變數筆記變數
- 整合學習
- jackson學習之九:springboot整合(配置檔案)Spring Boot
- Activiti工作流基礎學習筆記筆記
- Activiti 學習筆記12:分配個人任務筆記
- Activiti 學習筆記13:分配組任務筆記
- Activiti學習筆記三:管理流程定義筆記
- 工作流引擎Activiti與SpringBoot2整合--開源軟體誕生17Spring Boot
- 機器學習-整合學習機器學習
- jackson學習之十(終篇):springboot整合(配置類)Spring Boot
- Activiti 學習筆記八:排他閘道器(ExclusiveGateWay)筆記Gateway
- 一文帶你學習SpringBootSpring Boot
- SpringBoot學習日記(一)開始Spring Boot
- SpringBoot 學習Spring Boot
- springboot學習Spring Boot